spawnSync('npm', [install])则给出[Error: spawnpm ENOENT]

时间:2021-10-07 20:16:41

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

我有一个问题,spawnSync给我一个简单的“npm安装”。谁能帮帮我吗?

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

脚本节点= = = = = = = = = = = = = = = = =

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

var =孩子要求(“child_process”)。spawnSync(npm,['安装']);console.log(child.error);

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

========== ======[错误:spawnpm ENOENT]代码:'ENOENT', errno: 'ENOENT', syscall: ' spawnpm ',路径:'npm', spawnargs: ['install']

only on windows but not on OS X.

只在windows上,而不是OS X上。

  • This happens on
    • windows 7 x64
    • windows 7 x64
    • node version: 4.4.3
    • 节点版本:4.4.3
    • npm version: 2.15.1
    • npm版本:2.15.1
  • 这发生在windows 7 x64节点版本:4.4.3 npm版本:2.15.1

2 个解决方案

#1


3  

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']);

我解决了这个问题。在Windows上,有些命令需要后缀为.cmd才能工作。在本例中,这个更新的命令对我起作用:需要('child_process'). spawnsync ('npm)。cmd’,‘安装’);

#2


0  

Or you can use cross-spawn to make it work cross-platform

或者你可以使用交叉衍生使它在跨平台上工作

#1


3  

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']);

我解决了这个问题。在Windows上,有些命令需要后缀为.cmd才能工作。在本例中,这个更新的命令对我起作用:需要('child_process'). spawnsync ('npm)。cmd’,‘安装’);

#2


0  

Or you can use cross-spawn to make it work cross-platform

或者你可以使用交叉衍生使它在跨平台上工作