Vladyslav Marchenko
Vladyslav Marchenko

Reputation: 671

child_process.spawn ENOENT error

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

Upvotes: 0

Views: 1092

Answers (1)

Vladyslav Marchenko
Vladyslav Marchenko

Reputation: 671

Sorry, guys, it's my fault. somedir does NOT really exists. Closing the question

Upvotes: 1

Related Questions