How do I debug “Error: spawn ENOENT” on node.js?

后端 未结 25 2692
轻奢々
轻奢々 2020-11-22 03:00

When I get the following error:

events.js:72
        throw er; // Unhandled \'error\' event
              ^
Error: spawn ENOENT
    at errnoException (chil         


        
25条回答
  •  不思量自难忘°
    2020-11-22 03:22

    For ENOENT on Windows, https://github.com/nodejs/node-v0.x-archive/issues/2318#issuecomment-249355505 fix it.

    e.g. replace spawn('npm', ['-v'], {stdio: 'inherit'}) with:

    • for all node.js version:

      spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['-v'], {stdio: 'inherit'})
      
    • for node.js 5.x and later:

      spawn('npm', ['-v'], {stdio: 'inherit', shell: true})
      

提交回复
热议问题