I have Node/NPM installed on my (Linux) system. When I use an ordinary terminal, or the terminal inside VS Code, I can run npm
commands just fine.
However, when I try to use the “NPM Scripts” feature of VS Code (which lets you run your package.json
scripts from a pane in the “Explorer”), I see:
> Executing task in folder MyProject: npm run start <
/bin/sh: 1: npm: not found The terminal process terminated with exit code: 127
Terminal will be reused by tasks, press any key to close it.
It seems like VS Code uses a different user/shell/path/something to run these scripts, and as a result it can’t find the npm
command … but I have no idea what it’s using or how to fix it.
Advertisement
Answer
For some reason “NPM Scripts” function needs the npm file to be in /usr/local/bin/npm
. Try using your linux package manager to install npm (ex: sudo apt-get install npm) or install node.js again with the package from the website.
Another option would be to create a soft-link in /usr/local/bin/
pointing to the current installation.