5

When I use visual studio code to debug a nodejs app. visual studio code tell me request 'launch': cannot launch target (reason: spawn node ENOENT)

enter image description here

My nodejs version is 4.2.4

Luka Kerr
  • 4,161
  • 7
  • 39
  • 50
ChenPei
  • 51
  • 1
  • 2

4 Answers4

3

Managed to get past this when running on Windows by specifying npm.cmd instead of npm in the VS code debug configuration like so

"runtimeExecutable": "npm.cmd",
ebhh2001
  • 2,034
  • 4
  • 18
  • 27
2

Some discussions are posted in this here

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

Especially, the following points should be checked

  • Ensure the environment variable PATH is set
  • PATHEXT environment variable that can cause certain calls to spawn to not work on Windows.
Community
  • 1
  • 1
zangw
  • 43,869
  • 19
  • 177
  • 214
2

I was getting this error on a Debian Linux system. I noticed the same thing worked OK on Windows.

Next I noticed that the Node.JS executable is called node on Windows but on Debian (and on Debian-based systems such as Ubuntu) it's called nodejs. So I created an alias - from a root terminal, I ran

ln -s /usr/bin/nodejs /usr/local/bin/node

and this solved the problem.

MTGradwell
  • 151
  • 2
  • 2
1

This usually happens if you already had your Visual Code Editor running while installing node js on Windows OS. I would advise you to shut down your Visual Studio Code and restart it. This problem should go away.

If not do a machine reboot and verify if the debug works flawlessly

indcoder
  • 435
  • 1
  • 4
  • 11