I'm have some function like this
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
});
}
On Windows, Linux and Android machines I'm have the same error: ENOENT while trying to execute npm. It's present in process.env.PATH. What I'm doing wrong?
P.S. somedir
is defined and equal to an existing directory
Sorry, guys, it's my fault. somedir
does NOT really exists. Closing the question