visual studio code nodejs request 'launch': cannot launch target (reason: spawn node ENOENT)

后端 未结 4 1985
栀梦
栀梦 2021-01-18 18:52

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)

相关标签:
4条回答
  • 2021-01-18 19:13

    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.
    0 讨论(0)
  • 2021-01-18 19:14

    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",
    
    0 讨论(0)
  • 2021-01-18 19:21

    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.

    0 讨论(0)
  • 2021-01-18 19:29

    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

    0 讨论(0)
提交回复
热议问题