Visual Studio Code (Windows) does not detect global NPM modules
I am having an issue where Visual Studio Code on Windows 10 is unable to detect globally installed NPM packages in an integrated terminal.
For example, if on Windows command line I install @angular/cli
via command npm install -g @angular/cli
, on that command line I can execute @ angular / cli commands like ng --version
without error. After installing the global npm module in Visual Studio Code, doing the same ng --version
gives me an error:
The term "ng" is not recognized as the name of a cmdlet, function, script file, or operating program. Check the spelling of the name, or if the path was included, check the correct path and try again.
I can, however, successfully execute commands such as npm -v
and inside the integrated terminal node -v
.
I have the following items in my system environment variables
C:\Program Files\nodejs\
%AppData%\npm
Are there any Visual Studio Code user or system environment variables I am missing to enable npm global modules to be detected?
Thanks for any help you can provide.
source to share
I managed to solve the problem and use global npm commands in Visual Studio Code by changing my system environment path variables to position %AppData%\npm
before %ProgramFiles%\nodejs\
per npm troubleshooting tips
source to share
no need to do anything, just follow the steps given below -
- right click on my computer (this computer).
- go to properties.
- click on advanced system settings.
- click on environment variable.
- select the path variable from the system variable.
- click on the edit button.
- add% AppData% \ npm and% ProgramFiles% \ nodejs \ to the top of the list. 8 click on OK. Good. Good
- reboot your system.
- after restarting, open Visual Studio Code in Administrator Mode.
- Enjoy...............!!!!!
source to share
I found that adding %AppData%\npm
to the Path variable made it work for PowerShell and the command line, but it still didn't work for integrated PowerShell in VS Code.
When I changed it from %AppData%\npm
to the actual path where is your user directory, and reopened VS Code, it started working. C:\Users\<USER>\AppData\Roaming\npm
<USER>
source to share
it didn't work for me, i changed my path variable as C: \ oraclexe \ app \ oracle \ product \ 11.2.0 \ server \ bin ;; C: \ Program Files (x86) \ Common Files \ Oracle \ Java \ javapath;% SystemRoot% \ system32;% SystemRoot%;% SystemRoot% \ system32 \ Wbem;% SystemRoot% \ system32 \ WindowsPowerShell \ v1.0 \;% SystemRoot% \ system32 \ WindowsPowerShell \ v1.0 \;% SystemRoot% \ system32 \ WindowsPowerShell \ v1.0 \;% AppData% \ npm;% program files% \ nodejs \;% systemroot% \ System32 \ WindowsPowerShell \ v1.0 \; C: \ Program Files \ Java \ jdk1.8.0_211 \ bin; C: \ Program Files \ Java \ jdk1.8.0_211 \ bin; C: \ Bridgestone \ TESCAM_GIT \ codebase-bridgestone-tdc-tescam \ bridgestone-tdc-tescam-ui \ node_modules @angular \ cli \ bin
source to share