npm is installed using nvm but IntelliJ does not know about it

Raymond Pang picture Raymond Pang · Oct 25, 2016 · Viewed 11.4k times · Source

I installed NPM using NVM.

When I use npm in Intellij terminal, it says I don't have NPM installed. But if I use Ubuntu terminal, it is working.

Here are what I tried:

I have already tried to set my node interpreter (in "Language and Framework" > "Node and NPM", set to ~/.nvm/versions/node/v6.8.0/bin/node).

I have also already enabled the Node.js Core library. There it shows the npm package is included.

But the IntelliJ terminal still complains I haven't installed npm. Why?

Answer

Raymond Pang picture Raymond Pang · Dec 3, 2016

It is because idea terminal launches a login shell by default, so the .bashrc file is not read.

To solve the problem:

Open "Settings" in IntelliJ. Then, expand "Tools" in the left panel, then click 'Terminal'.

Add -i to the Shell Path. (eg. /bin/bash -i)