Reputation: 31
So i saw the execSync function in the nodejs api documentation.
https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options
I tried to run something like this.
var executeSync = function(command){
var child = require('child_process')
code = child.execSync(command);
return code;
}
But i get an error:
code = child.execSync(command);
^
TypeError: Object #<Object> has no method 'execSync'
So do i get something wrong with the versions ?
nvm ls
iojs-v3.3.1
v5.0.0
-> v5.4.0
system
default -> node (-> v5.4.0)
node -> stable (-> v5.4.0) (default)
stable -> 5.4 (-> v5.4.0) (default)
iojs -> iojs-v3.3 (-> iojs-v3.3.1) (default)
So why can't i use the execSync function ?
Upvotes: 0
Views: 409
Reputation: 203504
My guess is that you installed nodejs
, perhaps on Debian or Ubuntu, which provides an outdated Node (0.10.25).
You then installed nvm
to allow you to run more recent versions of Node, but kept on using the nodejs
executable instead of the node
executable (which is the commonly used name for the Node interpreter; nodejs
only exists on some Linux distro's because there's an unrelated node
package that had already taken the node
name).
In other words: run your code using node
, not nodejs
.
Upvotes: 1