Reputation: 1050
I wanna exec another .js
file with child_process.spawn. I'm using OSX.
The code is :
var server = spawn( '/Path/to/node', /.../server.js' );
And it is failed with :
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn /Users/GB/Dev/workspace_fe/www_ms/output/node/server.js ENOENT
at exports._errnoException (util.js:870:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
at Function.Module.runMain (module.js:443:11)
at startup (node.js:139:18)
at node.js:968:3
It's working well if only with command in shell /Path/to/node', /.../server.js
.
Upvotes: 0
Views: 1291
Reputation: 885
According to docs second argument of spawn must be array. Have you tried this:
var server = spawn( 'node', ['/path/to/server.js'] );
Upvotes: 3