![](/img/trans.png)
[英]Node.js mailparser module error: Cannot find module 'iconv'
[英]node.js: Error: Cannot find module
為什么會出現此錯誤?
Node v8.9.1
var childProcess = require('child_process'),
phantomjs = require('/var/bin/node_modules/phantomjs-prebuilt');
console.error = function(){
require('system').stderr.write(Array.prototype.join.call(arguments, ' ')+'\n');
phantomjs.exit(1);
};
console.log('hey', phantomjs.path)
console.error('error')
childProcess.execFile(phantomjs.path, require('system').args, function(err, stdout, stderr){
if(err){
console.error(err);
}
if(stderr){
console.error(stderr);
}
console.log(stdout);
});
# /var/bin/node_modules/phantomjs-prebuilt/bin/phantomjs phantom.js
Error: Cannot find module 'path'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
phantomjs://platform/phantomjs.js:10
hey undefined
TypeError: undefined is not a function (evaluating 'phantomjs.exit(1)')
phantomjs://code/phantom.js:6 in error
error
system
不是Node內置模塊, 而是PhantomJS的一部分 。 如果僅使用標准的node
命令運行腳本,則它將不可用。 如文檔所示 ,您需要使用phantomjs
命令,如下所示:
phantomjs phantom.js
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.