Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Npm command not found in visual studio code

Tags:

npm

Please tell me how i can solve it. Iam using window 7 32 bit:

enter image description here

like image 664
Japesh Thakur Avatar asked Jun 23 '18 11:06

Japesh Thakur


People also ask

Why npm is not recognized in VS code?

If you're calling npm from the VSCode terminal, you need to restart VSCode first before trying again. If you still get the error, then try restarting your computer first. The error should be gone after you restart. Now you should be able to install any npm package to your local computer with npm install command.

How do I get npm in Visual Studio?

To add the package. json file, right-click the project in Solution Explorer and choose Add > New Item (or press Ctrl + SHIFT + A). Use the search box to find the npm file, choose the npm Configuration File, use the default name, and click Add.

Why is npm command not found?

The npm command not found error The error above happens when npm can't be found under the PATH environment variable. First, you need to make sure that npm is installed on your computer. npm is bundled with Node. js server, which you can download from the nodejs.org website.


2 Answers

I too had this issue. To solve this follow the below steps. Make sure you have npm installed - go to command prompt & type npm -v - if a version comes out it's installed, else go to https://nodejs.org/en/ and download same. Then come to vs code and set deafult shell to cmd. to do so, - Press Ctrl+Shift+P and type Select Default Shell - Select Command Prompt. - Press Ctrl+` - Type npm -v and see npm works. :)

like image 149
JIJO JOSEPH Avatar answered Sep 25 '22 13:09

JIJO JOSEPH


By default, Visual Studio Code runs shell commands like npm in a loginless shell. If you installed NVM, Visual Studio Code may have no indication where to find npm to run it.

Put the following lines are in .bash_profile: (Note: Not .bashrc.)

export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion 

Add this setting to settings.json:

"terminal.integrated.shellArgs.linux": ["-l"]

like image 29
Jay Bienvenu Avatar answered Sep 25 '22 13:09

Jay Bienvenu