9

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?

SnirD
  • 708
  • 11
  • 22
  • 2
    Did you try to run `nvm use [YOUR_VERSION]` before run your rails application? – 19WAS85 Dec 30 '13 at 18:31
  • How is your Rails environment setup? The paths that nvm use could be missing from the path that passenger uses if you are using passenger. See my answer on http://stackoverflow.com/questions/14187681/node-js-not-found-by-rails-execjs/24020042#24020042 it may help you to diagnose the problem. – Travis Pessetto Jun 03 '14 at 16:22
  • @WagnerAndrade thanks! `nvm use` worked for me. – Ev Dolzhenko Oct 29 '15 at 21:06
  • @dolzenko, you might want to check out my answer, `nvm use` does not persist – James L. Mar 21 '17 at 21:43

2 Answers2

3

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.

James L.
  • 12,893
  • 4
  • 49
  • 60
1

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.

bonh
  • 2,863
  • 2
  • 33
  • 37