I'm using NVM to manage my Node.js versions on the system, and since I installed it my rails apps stop working.
ExecJS can't seem to find node runtime, giving the error:
Node.js (V8) runtime is not available on this system (ExecJS::RuntimeUnavailable)
what actions are needed to make NVM play well with ExecJS?
You can install and use NVM regardless of whether you have installed Node already. NVM alters path variables to select different versions of Node, so it works with pre-existing installations. Install NVM using either curl or wget .
nvm use node OR nvm use 11.10. This command will set the version of Node. js running locally to the latest version downloaded if you just type nvm use node , or the version specified if you append the command with the version number nvm use --version e.g. nvm use 8.15.
npm comes with Node. js so if you have node installed ( node --version ) you most likely have npm installed as well. You don't need nvm unless you you want to keep multiple versions of Node. js installed on your system or if you'd like to upgrade your current version.
Just ran into this issue myself. Basically, NVM is nice because it allows you to install and run multiple different versions of Node on one computer without sudo privileges. Since there are multiple versions, it does not automatically load a version in your shell for you, you have to specify which one you want to use. nvm use default
loads the default Node environment (instead of default you can specify a specific version) into the current shell, but this will stop working when the shell is closed. To make the change permanent, use nvm alias default node
, check out this issue for more info.
In our case, we're running Rails as a "regular" user with the command
bundle exec puma -C config/puma.rb
As long as you have a "default" node
set through nvm
, you should be okay.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
nvm install v0.12.7
nvm alias default v0.12.7
Next time you log in as that user, which node
should indicate the path under nvm
:
~/.nvm/versions/node/v0.12.7/bin/node
Likewise, Rails will pick up that node
as the one to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With