简体   繁体   中英

PhpStorm/WebStorm terminal shows old NPM version

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:

  • 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

在此处输入图片说明

Global packages from PhpStorm terminal

在此处输入图片说明

How do I get to the bottom of this?

Update

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?

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

在此处输入图片说明

Resolution

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM