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)
Please sign in to leave a comment.
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
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.
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)?
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?
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)?
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
Thanks! Adding -i from the terminal setting actually works. :)
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.
rc
config file (located in theterminal
folder underplugins
of WebStorm distribution) which provides an additional set-up, and then the user'src
file.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)
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?
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:.bashrc
to.bash_profile
).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
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
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
Igor, you totally nailed it!
Thanks
Igor Kalinovski, huge thanks! But it's may require relogin after described actions. Because in my case .nvm/current folder didn't exist.
I used Elena's method, and it worked really well. I prefered it to Igor's method, but if someone can tell me a reason why Igor's method is preferable, I will be very thankful.
I reached node/nvm/iTerm2 bliss in macOS Catalina by doing the following:
1. Moving everything I had in `.bashrc` to `.profile`
2. Changing `.bashrc` to just load `.profile` like so:
```
if [[ -f "${HOME}/.profile" ]]; then
source "${HOME}/.profile"
fi
```
3. Following the post above from Igor, to create a "default" symlink
Everything now works great!
I'm using nvm and zsh. Coping the values
to `~./profile` worked. My `~./zshrc` and `~./bashrc` do not have the export and I'm using the self created desktop entry from Intellij. Session restart was required.
Add export NVM_SYMLINK_CURRENT=true to your .bashrc before NVM-stuff. Then do nvm use default - symlink is created. (Igor Kalinovskiy), then go to settings and choose node interpreter from the folder for nvm's current node version.