relates SO question: http://stackoverflow.com/questions/19424696/rails-execjs-cant-find-node-when-using-nvm
is there some configuration I missing or simply this feature isn't supported?
You probably need to set your NODE_PATH environment variable - that's not really a supported use case for nvm.
Still an issue here: with system node (/usr/bin/node --version => v0.10.25) being an old version and nvm having newer versions (nvm current => v4.2.2) execjs takes the system node (setting NODE_PATH doesn't help).
Removing the system node did help (but that's not always possible).
@wvengen nvm is meant to provide a per-user per-shell version of node. If you're using it via rails, you'd need to update the system-installed node, or, use explicitly nvm use within ExecJS somewhere.
Thanks for explaining. Still I beg to differ: when running rails from the console after activating NVM, as a user I'd expect that the nvm-node version would be used.
After looking more into it, it seems that a cause is that the node binary is available through NVM, but not nodejs:
$ which nodejs
/usr/bin/nodejs
$ which node
/home/me/.nvm/versions/v4.2.2/bin/node
Since execjs looks for nodejs first, it finds the system node.
And yes, after running ln -s $(which node) $(which node)js it suddenly works.
What about including nodejs as well?
Ah - nodejs was installed via apt or something similar. It's highly nonstandard, and is one of the many reasons node shouldn't be installed via a distro package manager. execJS shouldn't be looking for it, nor prioritizing it, nor should it exist anywhere.
You'll want to apt-get remove nodejs (or whichever), and you may also wish to file an execJS issue about it.
Thanks - removing nodejs may not be possible in every situation, but execjs could certainly improve here - https://github.com/sstephenson/execjs/issues/197.
That helped in my case: https://coderwall.com/p/hyjdlw/make-rails-execjs-recognize-nodejs
doing this just solved my problem:
sudo ln -s $(which node) /usr/bin/node
Most helpful comment
Thanks for explaining. Still I beg to differ: when running rails from the console after activating NVM, as a user I'd expect that the nvm-node version would be used.
After looking more into it, it seems that a cause is that the
nodebinary is available through NVM, but notnodejs:Since execjs looks for
nodejsfirst, it finds the system node.And yes, after running
ln -s $(which node) $(which node)jsit suddenly works.What about including
nodejsas well?