描述: 上代码

var ps = require('child_process').spawn("npm", ['install'], {
    stdio: 'inherit',
    cwd: srcPath
});

ps.on('error', function(err) {
    console.log(err);
});

ps.on('exit', function (err) {
    console.log('exit');
});

执行报[Error: spawn ENOENT]

 

原因,windows下npm执行名不同

解决方案

var ps = require('child_process').spawn(process.platform === "win32" ? "npm.cmd" : "npm", ['install'], {
    stdio: 'inherit',
    cwd: srcPath
});

参考:http://stackoverflow.com/questions/17516772/using-nodejss-spawn-causes-unknown-option-and-error-spawn-enoent-err

相关文章:

  • 2021-09-04
  • 2021-10-20
  • 2021-06-25
  • 2021-11-20
  • 2021-10-26
  • 2022-12-23
  • 2021-04-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-09-08
相关资源
相似解决方案