Search code examples
npmenvironment-variablesvisual-studio-code

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.


Solution

  • I was able to resolve the issue and use global npm commands in Visual Studio Code by modifying my system environment path variables to position %AppData%\npm before %ProgramFiles%\nodejs\ per npm troubleshooting tips