npm is installed using nvm but IntelliJ doesn't know about it

I installed NPM using NVM by following this page : npm throws error without sudo. Everything works perfect in Ubuntu terminal. However, inside IntelliJ terminal, it says I don't have NPM installed. I have tried to set my node interpreter in Language and Framework > Node and NPM to~/.nvm/versions/node/v7.0.0/bin/node I have enabled the Node.js Core library, and from there I can see that npm package is included. But the terminal still say I haven't installed npm. Why?

(I have asked this in StackOverflow already but still cannot figure it out: http://stackoverflow.com/questions/40245370/npm-is-installed-using-nvm-but-intellij-doesnt-know-about-it

 

13 comments

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

3

I typed /opt/idea-IU-162.2032.8/bin/idea.sh in Terminal to launch intelliJ, Is this exactly what you mean by "launching from Terminal"? After that, I still cannot get the same environment variable and Node in intelliJ.

0

Very strange - Idea inherits terminal environment when being started in terminal, so everything should work. What are you doing namely? Can you describe your steps/attach screenshots that show up the issue (npm not recognized in Idea)?

0

then intellij is launched.



Node is not found and the PATH is different, how can I make the IntelliJ terminal work like in the first Terminal?

0

Hmm.. Can you attach a screenshot of your terminal settings (Settings | Tools | Terminal) and your idea.log (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files)?

0

Idea terminal launches a login shell by default, so your .bashrc file is not read. The workaround is adding `-i` parameter to bash in shell path settings. See http://taming-the-bits.logdown.com/posts/275357-how-to-improve-the-terminal-window-in-idea

2

Thanks! Adding -i from the terminal setting  actually works. :)

0

I had the same problem after IDE update and hated it going out of IDE. My issue was that fish is system shell for my system, and I did not need any config in IDE, but with this release, there was an option added Shell Integration just disable that, and it started working.

 

I got clue be reading the plugin documentation that this option adds one more layer for customization but for my system the whole system is configured hence do not need it.  

 

Disable it, and fish node nvm all started working.

 

Shell integration When this check box is selected, the terminal first loads a custom rc config file (located in the terminal folder under plugins of WebStorm distribution) which provides an additional set-up, and then the user's rc file.
1

That is because one of your PATH contains space.

I comment out the line `export PATH="/c/Program Files/erl9.1/bin:$PATH"` and logout login my system, then it works.

This bug was not here in IntellijIdea 2017 but appear in 2018 (2018.2.3)

0

I seem to run in a similar problem when starting IntelliJ from the "Jetbrains Toolbox". Node is recognized from the Terminal, however all services in the settings that require NodeJS (like NodeJS and NPM, ESLint, TSLint etc) all can't find the executable (see attached screenshot). 

If I start IntelliJ from the terminal, the executables can be found. In the Terminal settings, I've added `-i` to bash in the shell path, but to no avail. Any ideas how I can get this fixed?

0

When being launched from desktop/System menu, IDE only sees environment variables configured in ~/.profile (login shell), but not in interactive shell configuration files (like ~/.bashhrc). Possible workarounds:

  • Workaround 1: make required variables available in a login shell (i.e. for bash, move them from .bashrc to .bash_profile).
  • Workaround 2: run IDE from a terminal, via bin/idea.sh

see also https://youtrack.jetbrains.com/issue/IDEABKL-7589

> I've added `-i` to bash in the shell path, but to no avail

Terminal preferences (Settings | Tools | Terminal) only affect the built-in terminal

 

0

Thanks for your answer. 

In the end I had to add the code that loads NVM to the ~/.profile. When I added it to ~/.bash_profile it didn't seem to change anything, even though it states in the .profile that 

# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
0

Add export NVM_SYMLINK_CURRENT=true to your .bashrc before NVM-stuff. Then do "nvm use default" - symlink is created. Then add $HOME/.nvm/current/bin to your PATH in .profile

0

Please sign in to leave a comment.