简体   繁体   English

PhpStorm / WebStorm终端显示旧的NPM版本

[英]PhpStorm/WebStorm terminal shows old NPM version

I am on Windows 10 x64 running PhpStorm 2018.3 . 我在运行PhpStorm 2018.3 Windows 10 x64上。 I have updated NodeJS to 10.14.1 which includes NPM 6.4.1. 我已经将NodeJS更新到10.14.1,其中包括NPM 6.4.1。

The Windows command line tool shows the correct versions Windows命令行工具显示正确的版本 在此处输入图片说明

PhpStorm settings show the correct versions PhpStorm设置显示正确的版本 在此处输入图片说明

The problem I have is that the PhpStorm terminal still shows NPM 3.10.10 although it shows the correct Node version. 我遇到的问题是,尽管PhpStorm终端显示了正确的节点版本,但仍然显示NPM 3.10.10。

在此处输入图片说明

I have tried: 我努力了:

  • Restarting PhpStorm 重新启动PhpStorm
  • Restarting the computer 重新启动电脑
  • Uninstalling and re-installing Node, then restarting the computer 卸载并重新安装Node,然后重新启动计算机

This causes trouble because the version of NPM running in my IDE terminal cannot see the globally installed packages. 这会引起麻烦,因为在我的IDE终端中运行的NPM版本无法看到全局安装的软件包。

Global packages from Windows command line Windows命令行中的全局软件包

在此处输入图片说明

Global packages from PhpStorm terminal PhpStorm终端的全局软件包

在此处输入图片说明

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 在PhpStorm终端的where npm ,表明本地依赖项已安装较旧的NPM版本

在此处输入图片说明

在此处输入图片说明

Is it expected for a locally installed NPM to make it impossible for the terminal to see my global packages? 是否期望本地安装的NPM使终端无法看到我的全局软件包?

Update 2 更新2

When I run the Windows command line tool from within the project folder, everything works as expected, unlike the PhpStorm terminal. 当我从项目文件夹中运行Windows命令行工具时,一切正常,与PhpStorm终端不同。 The right version is seen, global packages are seen, and the where command cannot see the local NPM installed in node_modules 可以看到正确的版本,可以看到全局软件包,而where命令不能看到在node_modules中安装的本地NPM

在此处输入图片说明

Resolution 解析度

Thanks to Lena for the solution. 感谢Lena提供的解决方案。 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. 事实证明,使用PhpStorm 2018.3新的默认启用设置将项目本地./node_modules/.bin的二进制文件添加到$PATH ,因此终端将看到本地安装的NPM版本,而不是全局版本。 To resolve the issue I went to Settings > Tools > Terminal and unchecked this option: 要解决此问题,我转到了Settings > Tools > Terminal然后取消选中此选项:

Add node_modules/.bin from the project root to %PATH% 从项目根目录将node_modules / .bin添加到%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. 该问题是由于从项目根目录将'node_modules / .bin'添加到$ PATH设置|工具|终端 )-当您在node_modules/.binnpm二进制文件时,它也被添加到%PATH% ,因此在运行时使用终端中的npm Disabling this option should solve the issue 禁用此选项应该可以解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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