node.js - 错误: spawn ENOTDIR html-pdf in mac

标签 node.js meteor html-pdf

我正在使用[email protected]在我的 meteor 应用程序中。当 .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);

最佳答案

运行

npm update 

在您的项目文件夹中。它解决了我的问题!

关于node.js - 错误: spawn ENOTDIR html-pdf in mac,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48314131/

相关文章:

linux - Meteor 部署问题 : module did not self-register

javascript - 我怎样才能打印数组的数据?

node.js - Node.js中的exports.install是什么?

javascript - 更新 Meteor (mongoDB) 中对象数组中的字段

node.js - 带有html-pdf的AWS Lambda上的“ERROR Error: write EPIPE”

java - YaHP Converter 抛出 javax.xml.datatype.DatatypeConfigurationException

node.js - NodeJS 中的文件模块与文件夹模块

meteor - 在 Meteor 中存储每个用户的数据

Meteor - check() VS new SimpleSchema() 用于验证 .publish() 参数

node.js - 无法加载 PDF 文档 html-pdf