我正在使用 NVM 来管理系统上的 Node.js 版本,并且自从我安装它后,我的 rails 应用程序停止工作。
ExecJS 似乎找不到节点运行时,给出错误:
Node.js (V8) runtime is not available on this system (ExecJS::RuntimeUnavailable)
需要采取哪些措施才能使 NVM 与 ExecJS 良好配合?
我正在使用 NVM 来管理系统上的 Node.js 版本,并且自从我安装它后,我的 rails 应用程序停止工作。
ExecJS 似乎找不到节点运行时,给出错误:
Node.js (V8) runtime is not available on this system (ExecJS::RuntimeUnavailable)
需要采取哪些措施才能使 NVM 与 ExecJS 良好配合?
我自己也遇到了这个问题。基本上,NVM 很好,因为它允许您在一台计算机上安装和运行多个不同版本的 Node,而无需 sudo 权限。由于有多个版本,它不会自动为您在 shell 中加载一个版本,您必须指定要使用的版本。nvm use default
将默认的 Node 环境(而不是默认的,您可以指定特定版本)加载到当前 shell 中,但是当 shell 关闭时这将停止工作。要使更改永久生效,请使用nvm alias default node
,查看此问题以获取更多信息。
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.