node.jsbashnpmvisual-studio-code

VSCode tasks error: /bin/bash: npm: command not found


I've been using node and npm forever. Right now, however, when do command shift p, Tasks: Run task, npm build, I get this error message:

Executing task: npm install <

/bin/bash: npm: command not found The terminal process terminated with exit code: 127

Terminal will be reused by tasks, press any key to close it.

In the terminal, node and npm work fine. I even tried running /bin/bash; node -v and that works fine.


Solution

  • I found the solution. I had to tell nvm the default node version because I uninstalled a version before I had this error. See here: https://stackoverflow.com/a/34777308/1404347