Add a static symbolic link to current version of node #355

nikmartin opened this Issue Feb 6, 2014 · 16 comments


None yet

8 participants


Webstorm IDE has great built in support for node. One issue with it is that path to node has to be a full path, not an environment variable. Could nvm also create a symbolic link to the current version of node? I propose ~/.nvm/current/ I see #208 attempts this. but my ~/.nvm/bin is not a link, it is just a folder. Is this supposed to work?


The thing is, there is no "current" version since each terminal session has it's own nvm environment and you can be using several versions of node at the same time.

There is however, a global default alias. We could maybe create a symlink for this alias and update it after any install command that might potentially change where the alias points?


That would be perfect. I tried to figure out how the default alias could be linked, but couldn't grok it. If $NVM_DIR/bin/node was a link to the global default alias, that would make things work perfectly. I tried `which node`, $NVM_BIN, etc, and webstorm was having none of that.


Creating a symlink for alias would be a great option.
In my case, I'm strugling with provisionning using puppet + nvm + package (usin npm provider for package).

Details :
The trouble is that the session running the puppet agent (the shell) could'nt be updated. So I can't use environment variables to point to the right node bin dir dynamicaly (from one provisionning step to the other the session is a derivated one; can't propagate the changes made by mvn install).
But I could change the PATH setting (and add some specific node path to it).

For the moment I've to parse the alias to determine what version to point to.


+1. I'm running into an issue with a binary that wants a path to the node executable. For now I give it the path to a specific version of node (../nvm version/..), but in the future would prefer to give it a standard default path (symlink).


~/.nvm/`nvm version`/bin/node should work as of 13781f2 - I made the output of nvm version no longer have a leading newline and spaces.

UPDATE: use nvm which current.

@ljharb ljharb closed this in 8f66273 Jul 13, 2014

Could a symlink be made for aliases? So default or stable could be easily set with a path in editors?


Since aliases are in the filesystem, that would at least be possible - but see #89 for why it won't work.


~/.nvm/`nvm version`/bin/node doesn't seem to work anymore. The versions are now stored in ~/.nvm/versions/node/`nvm version`/. Or is something wrong with my setup?


@lehni hardcoding that path isn't a good idea, since it's both not guaranteed to stay constant, and, it's different depending on the node version. If you have nvm available, why would you need a hardcoded path to the node binary?


I'm not saying I need a hard-coded path, I'm just pointing out that your comment from February 16, 2014 isn't valid anymore, in case somebody else is wondering.


aha thanks :-) updated to use nvm which current


Thanks! So is it bad practice to have something like this in my .bash_profile?

source `dirname $(nvm which current)`/../lib/node_modules/npm/lib/utils/


since nvm which is a supported command, that part is fine, but you never want to hardcode node_modules anywhere. I think you want [ type npm >/dev/null 2>&1 ] && source <(npm completion) after nvm is sourced.


Great, thanks! That works too, and is much better.

And yes I agree, one should never hard-code those paths. But it still happens, just today I needed to hard-code the node path for

"osx": "/Users/lehni/.nvm/versions/node/v4.2.4/bin/node"

Definitely - inside editor settings is a different beast, mostly due to their inability to work properly with shell environments.


I have a solution for Sublime-HTMLPrettify that works on linux. I use this path

"linux": "/usr/local/bin/nodejs"

which targets on the following nodejs script

CMD="exec node"

for ARG in "$@"
  CMD="${CMD} \"${ARG}\""

. "/PATH/TO/.nvm/"

bash -c "$CMD"

I haven't test it thoroughly yet but it seems promising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment