Friday 14 April 2017

Node.js/Gulp: child process spawn 'Error: spawn EACCES'

I am trying to build and run an executable in Gulp using Node. My executable builds fine, however attempting to run it gives this error:

Error: spawn EACCES at exports._errnoException (util.js:1023:11) at ChildProcess.spawn (internal/child_process.js:313:11) at Object.exports.spawn (child_process.js:387:9) at Gulp. (/path/to/my/app/gulpfile.js:167:24) at module.exports (/path/to/my/app/node_modules/orchestrator/lib/runTask.js:34:7) at Gulp.Orchestrator._runTask (/path/to/my/app/node_modules/orchestrator/index.js:273:3) at Gulp.Orchestrator._runStep (/path/to/my/app/node_modules/orchestrator/index.js:214:10) at Gulp.Orchestrator.start (/path/to/my/app/node_modules/orchestrator/index.js:134:8) at Gulp. (/path/to/my/app/node_modules/gulp-sync/lib/index.js:51:27) at module.exports (/path/to/my/app/node_modules/orchestrator/lib/runTask.js:34:7)

Bear in mind that my script works perfectly fine when my gulpfile.js is in the same directory as the executable I am attempting to run.

But I have moved my gulpfile.js to one directory down, and in order to build/run the executable I have to change the cwd of the child process I am spawning to the directory above it. In doing so, even though the executable still builds find, the running of it keeps giving me this error and I can't find any help online.

Anyone have any ideas?

Here's the code:

// Spawn application server
if (os.platform() === 'win32') {
    // server = child.spawn(appName + '.exe') <-- USED TO WORK
    server = child.spawn(appName + '.exe', [], {
        cwd: mainDotGoPath
    });
} else {
    // server = child.spawn('./' + appName) <-- USED TO WORK
    server = child.spawn('./' + appName, [], {
        cwd: mainDotGoPath
    });
}

The path is fine, by the way, because I build the executable using a similar syntax and it builds just fine:

var build = child.spawnSync('go', ['build'], {
    cwd: mainDotGoPath
});



via Lansana

No comments:

Post a Comment