Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node version is different in PhpStorm and Ubuntu

After updating node my PhpStorm terminal is still showing the older version while my Ubuntu terminal is showing the updated version.

I came across this issue when running npm start and npm install were both failing due to incompatible node version.

After running which node on both terminals I get these results:

  • PhpStorm: /bin/node
  • Ubuntu: /usr/local/bin/node

Trying the top answer to this question didn't work for me: PhpStorm/WebStorm terminal shows old NPM version

like image 482
Virtual Shaman Avatar asked May 17 '26 08:05

Virtual Shaman


1 Answers

The problem is because JetBrains IDEs can alter your $PATH env var when it starts a terminal. Check your settings in your Settings | Tools | Terminal section. There are a few settings that may need to be altered. Look for anything that mentions $PATH:

Add default project PHP interpreter to $PATH - Unless you are purposefully maintaining separate php versions for different projects, you can safely uncheck this. If your PHP interpreter is set to /bin or /usr/bin it could be prepending that to your $PATH and thus overriding /usr/local/bin for your node and npm binaries. If you want to purposefully use a separate php version for a project, I would recommend installing it in a separate directory so as not to conflict with other binaries.

Add 'node_modules/.bin' from the project root to $PATH - If you have npm installed in your node_modules/.bin, then you may want to use it rather than your global npm. However, according to https://youtrack.jetbrains.com/issue/WEB-33571, this setting will now append node_modules/.bin to your $PATH and therefore your global npm will be used. This is probably the desired behavior, but if you do want to use the version from node_modules/.bin, then you'll need to either call it directly (ie. node_modules/.bin/npm start) or add it to your $PATH manually in ~/.bashrc.

(add export PATH="path/to/project/node_modules/.bin:$PATH" to the bottom of your ~/.bashrc file, then restart your terminal or run source ~/.bashrc)

like image 178
knsheely Avatar answered May 20 '26 17:05

knsheely



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!