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

后端 未结 25 3247
轻奢々
轻奢々 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:39

    I was getting this error when trying to debug a node.js program from within VS Code editor on a Debian Linux system. I noticed the same thing worked OK on Windows. The solutions previously given here weren't much help because I hadn't written any "spawn" commands. The offending code was presumably written by Microsoft and hidden under the hood of the VS Code program.

    Next I noticed that node.js is called node on Windows but on Debian (and presumably 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. The same or a similar procedure will presumably work in other cases where your node.js is called nodejs but you're running a program which expects it to be called node, or vice-versa.

提交回复
热议问题