作業と異なるディレクトリにファイルを書く私は、PDFフォルダ内のファイルにassets.jsからファイルを記述する必要が、今、このディレクトリ
のように私のプロジェクト構造の何かを持っています。私は
var qrImgPath = '/lib/pdf/' +eod+'.png';
fs.writeFile(qrImgPath,body,'binary',function(err){
return next();
});
をしようとしていますが、私はエラー
{ handle: 2,
type: 'error',
className: 'Error',
constructorFunction: { ref: 5 },
protoObject: { ref: 6 },
prototypeObject: { ref: 1 },
properties:
[ { name: 'stack',
attributes: 2,
propertyType: 3,
ref: 1 },
{ name: 'arguments',
attributes: 2,
propertyType: 1,
ref: 1 },
{ name: 'type',
attributes: 2,
propertyType: 1,
ref: 1 },
{ name: 'message',
attributes: 2,
propertyType: 1,
ref: 7 },
{ name: 'errno',
propertyType: 1,
ref: 8 },
{ name: 'code',
propertyType: 1,
ref: 9 },
{ name: 'path',
propertyType: 1,
ref: 10 } ],
text: 'Error: ENOENT, open \'/lib/pdf/b0551796a741aa885e641dbd895a233f.png\'' }
次取得していますものです
。
これをどのように達成できますか?
のように相対パスを使用してください: 'var qrImgPath = '../../lib/pdf/' + eod + '。png';' –
@JonathanBrooksはまだ同じエラー –
このエラーは '/ lib/pdf/b0551796a741aa885e641dbd895a233f.png'は存在しません。 'fs.existsSync( '/ lib/pdf/b0551796a741aa885e641dbd895a233f.png')'を実行すると、その存在をテストできます。 – Lewis