child_process.spawn ENOENT错误

时间:2017-10-09 14:26:44

标签: node.js child-process spawn enoent

我有这样的功能

if (isset(get_headers("www.websitedoesntexist.com"))) {
    echo "URL Exists";
}

在Windows,Linux和Android机器上,我有同样的错误:在尝试执行npm时ENOENT。它出现在process.env.PATH中。我做错了什么?

P.S。 function startMain(){ child_process.spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install'], { cwd : somedir, stdio : 'inherit' }).on('close',()=>{ child_process.spawn('node', ['app'], { cwd : somedir, stdio : 'inherit' }).on('error', (err)=>{ console.log('Error occured during starting. Aborting...\nError stack: Cannot exec node\n'); throw(err); // something wrong with spawn }); }).on('error', (err)=>{ console.log('Error occured during starting. Aborting...\nError stack: Cannot exec npm\n'); throw(err); // something wrong with spawn }); } 已定义且等于现有目录

1 个答案:

答案 0 :(得分:1)

对不起,伙计们,这是我的错。 somedir并不存在。结束问题