Reputation: 40896
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
PhpStorm settings show the correct versions
The problem I have is that the PhpStorm terminal still shows NPM 3.10.10 although it shows the correct Node version.
I have tried:
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
Global packages from PhpStorm terminal
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
Is it expected for a locally installed NPM to make it impossible for the terminal to see my global packages?
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
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.
Upvotes: 6
Views: 3345
Reputation: 3496
In my case, I was seeing Version 12.xx.xx in the PHPStorm terminal. But since I am now using nvm, and --using nvm-- had installed the latest version of node (v20.13.1). I was seeing the latest version in the system terminal.
After some research, I ran across this info on installing Node via APT (and the warning message) at Digital Ocean
Ubuntu 22.04 contains a version of Node.js in its default repositories that can be used to provide a consistent experience across multiple systems. At the time of writing, the version in the repositories is 12.22.9. This will not be the latest version, but it should be stable and sufficient for quick experimentation with the language
Since I am now using nvm, I don't really need that 12.xx.xx version that shipped with 22.04 ..and so!
$ sudo apt remove nodejs
$ sudo apt purge nodejs
PHPStorm, now shows the correct version.
Upvotes: 1
Reputation: 73984
I had the same problem with Ubuntu, the Terminal setting for "node_modules/.bin" did not work for me, it was already disabled.
With "which node", you can get the path of the node binary. If you get the wrong version with "node -v", it is likely that the path is different.
In my case, the path in the PHPStorm Terminal was "/bin/node", but the path in the regular Terminal was "/usr/local/bin/node". So i compared $PATH and found out that PHPStorm added "/bin" as first entry, which might not be a problem though.
Solution:
Upvotes: 2
Reputation: 93768
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
Upvotes: 5