Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code (Windows) Not Detecting Global NPM Modules

I'm experiencing an issue where Visual Studio Code in Windows 10 is not able to detect globally installed NPM packages within the Integrated Terminal.

For example, if the windows command prompt I install @angular/cli via command npm install -g @angular/cli, within that command prompt I can execute @angular/cli commands such as ng --version without error. After that global npm module install, within Visual Studio Code, performing the same ng --version gives me the error:

The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I can however within the integrated terminal successfully perform commands such as npm -v and node -v.

I have the following items in my system environment variables

C:\Program Files\nodejs\

%AppData%\npm

Are there Visual Studio Code user or system environment variables I'm missing to allow detection of global npm modules?

Thank you for any help you can provide.

like image 423
Alexander Staroselsky Avatar asked Jul 27 '17 15:07

Alexander Staroselsky


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 fix npm not recognized?

npm is not recognized as internal or external command operable program or batch file. I figured out that node js is installed in C:\Program Files\nodejs. Opening a command prompt in this directory makes npm work fine.

How do I install npm globally?

Install Package Globally NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.


1 Answers

Visual Studio Code must be "Run as Administrator" for working Terminal Commands.

like image 68
Jnyanendra Sethi Avatar answered Oct 13 '22 01:10

Jnyanendra Sethi