PhpStorm/WebStorm Terminal Shows Old NPM Version

- 1 answer

I am on Windows 10 x64 running PhpStorm 2018.3. I have updated NodeJS to 10.14.1 which includes NPM 6.4.1.

The Windows command line tool shows the correct versions enter image description here

PhpStorm settings show the correct versions enter image description here

The problem I have is that the PhpStorm terminal still shows NPM 3.10.10 although it shows the correct Node version.

enter image description here

I have tried:

  • Restarting PhpStorm
  • Restarting the computer
  • Uninstalling and re-installing Node, then restarting the computer

This causes trouble because the version of NPM running in my IDE terminal cannot see the globally installed packages.

Global packages from Windows command line

enter image description here

Global packages from PhpStorm terminal

enter image description here

How do I get to the bottom of this?


Running where npm from the PhpStorm terminal shows that a local dependency has installed the older NPM version

enter image description here

enter image description here

Is it expected for a locally installed NPM to make it impossible for the terminal to see my global packages?

Update 2

When I run the Windows command line tool from within the project folder, everything works as expected, unlike the PhpStorm terminal. The right version is seen, global packages are seen, and the where command cannot see the local NPM installed in node_modules

enter image description here


Thanks to Lena for the solution. Turns out that with PhpStorm 2018.3, a new enabled-by-default setting adds the binaries in the project's local ./node_modules/.bin to $PATH, so the terminal would see the locally installed NPM version instead of the global one. To resolve the issue I went to Settings > Tools > Terminal and unchecked this option:

Add node_modules/.bin from the project root to %PATH%

If anyone involved is reading this, I would suggest allowing the user to add a blacklist of binaries that should not be added when this option is checked.



The problem is caused by Add 'node_modules/.bin' from the project root to $PATH (Settings | Tools | Terminal) - as you have npm binary in node_modules/.bin, it's also added to %PATH% and thus used when running npm in terminal. Disabling this option should solve the issue