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?
To see if NPM is installed, type npm -v in Terminal. This should print the version number so you'll see something like this 1.4. 28. Create a test file and run it.
nvm doesn't handle npm. So if you want to install Node. js 0.4. x (which many packages still depend on) and use NPM, you can still use npm 1.0.
NVM is a node. js version manager. It provides easy installation, switching between versions and retains globally installed packages for each version. NPM is a package manager, which help you install libraries, plugins, frameworks and applications.
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)
This fixed it for me:
NVM patches environment variables on terminal startup only. If the IDE is launched from Terminal, it inherits Terminal environment (including modified PATH environment variable, added NVM_DIR env var, etc). In that case, there are normally no problems with using node/npm, because Idea sees the correct PATH value. For bash as shell, workaround could be the the following: edit your Idea launcher and set command to "/bin/bash -l -c "/path/to/idea.sh". This command will perform bash login (i.e. reading your .bashrc/.bash_profile files) and after that will run idea
https://intellij-support.jetbrains.com/hc/en-us/community/posts/205964744/comments/205060164
Just edit your Intellij launcher / startup script and change that to /bin/bash -i -c <path to idea.sh>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With