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.

+15


source to share


7 replies


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



+16


source


Visual Studio Code must be "Run as Administrator" for terminal working commands.



+12


source


no need to do anything, just follow the steps given below -

  1. right click on my computer (this computer).
  2. go to properties.
  3. click on advanced system settings.
  4. click on environment variable.
  5. select the path variable from the system variable.
  6. click on the edit button.
  7. add% AppData% \ npm and% ProgramFiles% \ nodejs \ to the top of the list. 8 click on OK. Good. Good
  8. reboot your system.
  9. after restarting, open Visual Studio Code in Administrator Mode.
  10. Enjoy...............!!!!!

enter image description here

+3


source


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>

0


source


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

0


source


Run Visual Studio Code as Administrator. Then enter the ng command.

0


source


You can fix the problem by opening VS Code terminal and type

npm install -g @ angular / cli

This should fix the problem.

-2


source







All Articles