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.

3
30 comments
Avatar
Permanently deleted user

 

Tried fresh install but the problem still occurs. 

0

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
Avatar
Permanently deleted user

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

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"

4
Avatar
Permanently deleted user

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

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
Avatar
Permanently deleted user

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

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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.

10
Avatar
Permanently deleted user

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

>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)

1

>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.

1

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

0
Avatar
Permanently deleted user

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

0

Thank you @.... 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) ? 

3
Avatar
Permanently deleted user

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

+ following

0

+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

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

0

The problem referred to in https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000160444/comments/360000197819 by @... is also happening to me. Didn't find a way to work around it yet...

3

Oksana Chumak can you please check if there are any updates on this?

0

My workaround to always run phpstorm with the right environment variables:

I modified the Toolbox "Shell scripts location" option from `/home/bertho/bin` to `/usr/bin`

And I created a `/usr/local/bin/phpstorm` (with `chmod +x`):

#!/usr/bin/zsh

/bin/zsh -l -i -c "/usr/bin/phpstorm" "$@"
0

How is that an expected behavior !! Then what's the point in setting the node version in both the run config and project level !! 

-1

>Then what's the point in setting the node version in both the run config and project level !! 

the IDE can start the specified version when running Node.js apps; but there is no way for the IDE to inject it in the scripts that are used in the calls chain where node is only references by name and resolved from PATH

1

That's really the expected behavior tho, it'd be easier for me if you wrote that we're marginal users and the priorities for this is too low for even discussing. But you're saying that the behavior is as expected, well, we definitely expected something else, didn't we...?

Think about our use case:

  1. We commit to git (really basic stuff)
  2. It fails due to a wrong node version 
  3. We attempt to fix it, and great news, we can change the node version for this project alone!
  4. We change it and nothing happens.

We log into IntelliJ support and turns out we have bad expectations. Yes... That's not a great support experience, to say the least.

0

After a while, I have discovered that what they are saying is true. This is the expected behavior because it's related to the system node version which all the apps use by default. even if you have multiple versions in the system. For me, I solved the issue by removing nodes from the system completely and use nvm to install the appropriate version.  You also need to add a symbolic link in /use/bin/node if you encountered some error saying that node can't be found.

2

That is the exact solution that I used. But, changing the system's node is really a walkaround. I need a different version for different projects, that's exactly the reason, I guess, why IntelliJ has added the ability to change node version, to begin with.

0
Avatar
Permanently deleted user

The solution that worked for me was to add my path from terminal to the environment section of the run config.

0

Please sign in to leave a comment.