Node.js 错误:在mac中生成ENOTDIR html pdf
我正在我的meteor应用程序中使用。调用Node.js 错误:在mac中生成ENOTDIR html pdf,node.js,meteor,html-pdf,Node.js,Meteor,Html Pdf,我正在我的meteor应用程序中使用。调用.create()时,将生成以下错误最初它正在工作,但在更新Mac Sierra后,它会产生以下错误。但是它在ubuntu操作系统中运行 W20180118-09:52:33.939(5.5)? (STDERR) Error: spawn ENOTDIR W20180118-09:52:33.940(5.5)? (STDERR) at exports._errnoException (util.js:907:11) W20180118-09:52
.create()
时,将生成以下错误最初它正在工作,但在更新Mac Sierra后,它会产生以下错误。但是它在ubuntu操作系统中运行
W20180118-09:52:33.939(5.5)? (STDERR) Error: spawn ENOTDIR
W20180118-09:52:33.940(5.5)? (STDERR) at exports._errnoException (util.js:907:11)
W20180118-09:52:33.940(5.5)? (STDERR) at ChildProcess.spawn (internal/child_process.js:298:11)
W20180118-09:52:33.941(5.5)? (STDERR) at Object.exports.spawn (child_process.js:362:9)
W20180118-09:52:33.941(5.5)? (STDERR) at PDF.PdfExec [as exec] (/Users/vineet/fees-mcop-141017/node_modules/html-pdf/lib/pdf.js:87:28)
W20180118-09:52:33.942(5.5)? (STDERR) at PDF.PdfToBuffer [as toBuffer] (/Users/vineet/fees-mcop-141017/node_modules/html-pdf/lib/pdf.js:44:8)
W20180118-09:52:33.942(5.5)? (STDERR) at route.js:646:41
W20180118-09:52:33.943(5.5)? (STDERR) at packages/meteor/helpers.js:118:1
W20180118-09:52:33.947(5.5)? (STDERR) at route.js:674:17
W20180118-09:52:33.947(5.5)? (STDERR) at [object Object].<anonymous> (route.js:574:29)
W20180118-09:52:33.948(5.5)? (STDERR) at boundNext (packages/iron_middleware-stack/lib/middleware_stack.js:251:1)
W20180118-09:52:33.939(5.5)?(STDERR)错误:spawn ENOTDIR
W20180118-09:52:33.940(5.5)?(STDERR)at exports.\u errnoException(util.js:907:11)
W20180118-09:52:33.940(5.5)?(STDERR)位于ChildProcess.spawn(internal/child_process.js:298:11)
W20180118-09:52:33.941(5.5)?(STDERR)位于Object.exports.spawn(child_process.js:362:9)
W20180118-09:52:33.941(5.5)?(STDERR)位于PDF.PdfExec[as exec](/Users/vineet/fees-mcop-141017/node_modules/html PDF/lib/PDF.js:87:28)
W20180118-09:52:33.942(5.5)?(STDERR)见PDF.PdfToBuffer[作为toBuffer](/Users/vinet/fees-mcop-141017/node_modules/html PDF/lib/PDF.js:44:8)
W20180118-09:52:33.942(5.5)?(标准)路线js:646:41
W20180118-09:52:33.943(5.5)?(STDERR)在packages/meteor/helpers.js:118:1
W20180118-09:52:33.947(5.5)?(标准)在路线上。js:674:17
W20180118-09:52:33.947(5.5)?(STDERR)位于[object]。(route.js:574:29)
W20180118-09:52:33.948(5.5)?(STDERR)在boundNext(packages/iron_middleware-stack/lib/middleware_stack.js:251:1)
代码:-
let content=fs.readFileSync(process.env.PWD+'/public/html/itc.html');
让编译=模板(内容);
让todayDate=moment().format('DD-MMM-YYYY');
让itcPDFCompiled=compiled({
headername:headername
});
让选项={
格式:“A4”,
“标题”:{“高度”:“5mm”},
“页脚”:{
“高度”:“8mm”,
“内容”:{
默认值:“”+todayDate+“”,
}
}
};
var requestSync=Meteor.wrapAsync(函数(itcPDFCompiled、选项、回调){
创建(itcPDFCompiled,options).toFile(路径+文件名+'.pdf',函数(err,res){
如果(错误)
回调(err);
其他的
回调(空);
});
});
requestSync(itcPDFCompiled,选项);
运行
在项目文件夹中。它解决了我的问题 升级到Mac OS High Sierra后,我也遇到了同样的情况。
npm install-g phantomjs
之后的npm rebuild
工作。当系统中缺少基础库时,可能会引发此错误。在我的例子(mac os x)中,缺少的库是sshpass
在Sierra更新之后,您是否重新运行了meteor npm install
?可能有些更改需要根据更新的环境构建包。我也遇到了这个错误。解决这个问题运气好吗?我也犯了这个错误!
let content = fs.readFileSync(process.env.PWD + '/public/html/itc.html');
let compiled = template(content);
let todayDate = moment().format('DD-MMM-YYYY');
let itcPDFCompiled = compiled({
headername: headerName
});
let options = {
format: 'A4',
"header": { "height": "5mm" },
"footer": {
"height": "8mm",
"contents": {
default: '<span style="color: #444;float:right;padding:0px 10px;font-size:10px;">' + todayDate + '</span>',
}
}
};
var requestSync = Meteor.wrapAsync(function (itcPDFCompiled, options, callback) {
pdf.create(itcPDFCompiled, options).toFile(path + file_name + '.pdf', function (err, res) {
if (err)
callback(err);
else
callback(null);
});
});
requestSync(itcPDFCompiled, options);
npm update