我在我的流星应用中使用html-pdf@2.1.0。当.create()
调用时,然后错误生成。 最初它正在运行但在更新Mac Sierra后会产生以下错误。但是它在 ubuntu os 中工作。
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)
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);
答案 0 :(得分:0)
运行
npm update
项目文件夹中的。它解决了我的问题!
答案 1 :(得分:0)
升级到Mac OS High Sierra后,我也发生了同样的事。
npm install -g phantomjs
后跟npm rebuild
工作。
答案 2 :(得分:0)
当系统中缺少基础库时,可能会抛出此错误。在我的情况下(mac os x),缺少的库是sshpass