0

我有这样的功能

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
    });
}

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

PSsomedir已定义且等于现有目录

4

1 回答 1

1

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

于 2017-10-10T04:45:53.810 回答