Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spawnSync('npm', ['install']) gives [Error: spawnSync npm ENOENT]

Tags:

node.js

I am having an issue with spawnSync is giving me ENOENT with simple "npm install". Can someone please help me?

======= NODE SCRIPT ==========

var child = require('child_process').spawnSync('npm', ['install']); console.log(child.error);

===== OUTPUT ========== [Error: spawnSync npm ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawnSync npm', path: 'npm', spawnargs: [ 'install' ]

only on windows but not on OS X.

  • This happens on
    • windows 7 x64
    • node version: 4.4.3
    • npm version: 2.15.1
like image 748
Henry Zou Avatar asked May 09 '16 21:05

Henry Zou


1 Answers

I figured out the issue. On Windows, some commands need to be suffixed with .cmd in order to work. In this example, this updated command works for me: require('child_process').spawnSync('npm.cmd', ['install']);

like image 149
Henry Zou Avatar answered Oct 30 '22 18:10

Henry Zou