Wrong node version used when running from 'run' (after update to Webstorm 2018)

After updating to Webstorm 2018 my run scripts started to take wrong node version into account.

I have a correct setup in run script configuration but nevertheless they run using the newest global from the system rather than specified there.

When running from terminal everything runs fine. Only run option doesn't work.

 

Run tries to use 9.x

While I explicitly ask to use 8.2.

20 comments
Comment actions Permalink

No, nothing new, it has always worked this way. When being launched from desktop/System menu, WebStorm only sees environment variables configured in ~/.profile (login shell), but not in interactive shell configuration files (like ~/.zshrc).
Possible workarounds:
- Workaround 1: make required variables available in a login shell (i.e. for Zsh, move them from .zshrc to .zprofile).
- Workaround 2: run IDE from a terminal
- Workaround 3: edit the desktop launcher and set command to /bin/zsh -l -i -c "/path/to/webstorm.sh"

2
Comment actions Permalink

This may be related -- I was having issues running my pre-commit hook because WebStorm does not respect the node version in settings. I set the version to 8.12.0, but the pre-commit hook runs with 10.11.0:

Turns out WebStorm just grabs whatever the default is for the hooks and ignores whatever preference you set.

2
Comment actions Permalink

We have a ticket for this - https://youtrack.jetbrains.com/issue/IDEABKL-7589; but this is the expected behavior, not a problem with IDE.

1
Comment actions Permalink

Sorry, but Webstorm has never loaded environment variables from interactive shell when being started from desktop/menu. I have no idea why it works for you in previous version

1
Comment actions Permalink

 

Tried fresh install but the problem still occurs. 

0
Comment actions Permalink

Looks like a $PATH issue. Sass doesn't use Node.js interpreter set up in your IDE, it uses yarn and node binaries found in $PATH. Try running WebStorm from terminal using webstorm.sh - does the issue persist?

0
Comment actions Permalink

Thank you for a quick reply.

Yes, everything works fine when running from terminal. 

I have:

 export PATH="$PATH:/home/alex/Software/WebStorm/bin" 

added into .zshrc and the previous version seemed to be ok with that :)

Something new I have to add/change for 2018?

 

0
Comment actions Permalink

I've changed the default script: 

/usr/local/bin/webstorm

to:

#!/usr/bin/zsh

/bin/zsh -l -i -c /home/alex/Software/WebStorm/bin/webstorm.sh

And seems to work fine. But this is a workaround of an issue. Should I create a ticket in the issue tracker?

0
Comment actions Permalink

How this is not a problem with IDE when if I install an older version of Webstorm everything works fine and when Webstorm 2018 it doesn't work and I have to do some shady workarounds?

All settings, paths in config files etc. are the same - the only change is the version of IDE. One works, other doesn't...

Edit: And yes, I tried downgrading and if I downgrade to last 2017 version everything works fine.

0
Comment actions Permalink

Also happens in OSX High Sierra 10.13.4 when trying to use NVM.

I've tried to move nvm initialization from .zshrc to .zprofile to no avail.

The problems also started after upgrading to Webstorm 2018 after three years with the same exact setup.

0
Comment actions Permalink

I'm using IntelliJ idea on mac OS Mojave. For me, this seems to happen only when using yarn. I added 'echo $PATH;' to a simple script in package.json to verify what gets added to the path and using yarn, Idea adds the system node version to the path while using npm, the version provided in the dialog is added.

0
Comment actions Permalink

>using yarn, Idea adds the system node version to the path while using npm, the version provided in the dialog is added.

When running npm scripts, IDEA passes --scripts-prepend-node-path option to npm: if it is passed, the directory within which node resides is added to the PATH. This is done to ensure that all spawned node child processes use the same Node.js version as chosen in run configuration. This flag is not passed to yarn because it has issues with it (it doesn't work in all yarn versions)

0
Comment actions Permalink

>Also happens in OSX High Sierra 10.13.4 when trying to use NVM.I've tried to move nvm initialization from .zshrc to .zprofile to no avail.

this workaround only works on Linux. On Mac, the IDE tries to load terminal environment by executing the following command on startup:

<your shell> -l -i -c '/Applications/webstorm.app/bin/printenv.py'

Seems this command can't retrieve all needed stuff in your case - thus the issue.

0
Comment actions Permalink

Leyan Lo I'm experiencing the exact same issue. Did you find a workaround ? 

0
Comment actions Permalink

@Contacto I now commit in a separate terminal, or commit in WebStorm unchecking Run git hooks :-/

0
Comment actions Permalink

Thank you Leyan Lo. I do the same, though it's not ideal. I have also tried appending `npx nvm use` to the git hook command, considering I have a `.nvmrc` file on the project. Still I can't make the pre-commit hook environment to use proper node version. I'm doing that on a Mac by the way. 

Elena Pogorelova do you know if there is any update on this ? Or if there is any YouTrack issue I could subscribe to, in order to receive updates (the issue you've mentioned earlier on the thread is targeting Linux) ? 

0
Comment actions Permalink

At the moment I am also working with git in a separate terminal. 

I am subscribing to this thread to find out when this is resolved.

0
Comment actions Permalink

+1 to request fix. Seems to be a problem for IntelliJ as well. 

Very crude workaround is to set default node using nvm and restart intellij.

nvm alias default 10

Obviously this requires restarts when switching between projects that use different versions.

0
Comment actions Permalink

Still seeing this in Intelli Ultimate 2020.1.  A rare annoyance for sure, workaround for me was to just git cli.

0

Please sign in to leave a comment.