Rails/execjs 找不到 Node.js [英] Node.js not found by Rails / execjs
问题描述
我通过从 root 用户编译和安装 node.js 来安装它.我想这可能是挂断的地方.从运行 rails 应用程序的用户那里,我检查了 node.js.
I have node.js installed by compiling and installing it from the root user. I think this maybe where the hangup is. From the user running the rails app I checked for node.js.
$ which node
/usr/local/bin/node
当我启动我的 Rails 应用程序(Rails 3.2.9)时,我得到了普遍无益的我们很抱歉,但出了点问题".检查生产错误日志,我发现未找到 Javascript 运行时.这很令人困惑,因为它显然已安装.所以我开始强制 Node javascript 运行时.我编辑了 config/boot.rb 以包括:
When I launched my rails app (Rails 3.2.9) I get the universally unhelpful "We're sorry, but something went wrong." Checking the the production error log I saw that the Javascript runtime was not found. That's confusing as it is obviously installed. So I went about forcing the Node javascript runtime. I edited config/boot.rb to include:
ENV['EXECJS_RUNTIME'] = 'Node'
我在查看生产日志的同时再次检查了我的应用程序.这次我得到了错误
I checked my app again, while watching the production log. This time I got the error
ActionView::Template::Error (Node.js (V8) runtime is not available on this system
还是一头雾水.我去了 execjs gem 并将运行时命令更改为确切的安装路径.
Still confused. I went to the execjs gem and changed the runtime command to the exact installed path.
Node = ExternalRuntime.new(
:name => "Node.js (V8)",
:command => "/usr/local/bin/node",
:runner_path => ExecJS.root + "/support/node_runner.js",
:encoding => 'UTF-8'
)
我仍然遇到同样的错误.节点已安装并可供用户访问,但 gem/rails 似乎无法使用它.服务器运行 CentOS 6.3.导致抛出错误的特定 javascript 文件是 jquery.nivo.slider.pack.js.从 nivo 下载后我没有编辑它.
I still get the same error. Node is installed and accessible by the user but the gem/rails can't seem to use it. The server is run CentOS 6.3. The specific javascript file causing the error to be thrown is jquery.nivo.slider.pack.js. Which I didn't edit after downloading it from nivo.
推荐答案
我在我的 centos 6.3 系统上使用源代码安装 nodejs 时遇到了类似的问题.它已成功安装,但我一直无法编译我的 ror 应用程序资产,直到我明确将 PATH 设置为它的安装位置(nodejs)
I have had similar issue installing nodejs with source on my centos 6.3 system. It was successfully installed but I keep failing in compiling my ror app assets until I explicitly set the PATH to where it was installed (nodejs)
[root]# 安装
...
安装/usr/local/lib/node_modules/npm/html/doc/folders.html
符号链接 ../lib/node_modules/npm/bin/npm-cli.js ->/usr/local/bin/npm
将/usr/local/bin/npm 的 shebang 更新为/usr/local/bin/node
[root]# make install
...
installing /usr/local/lib/node_modules/npm/html/doc/folders.html
symlinking ../lib/node_modules/npm/bin/npm-cli.js -> /usr/local/bin/npm
updating shebang of /usr/local/bin/npm to /usr/local/bin/node
[root]# export PATH=/usr/local/bin:$PATH
[root]# export PATH=/usr/local/bin:$PATH
现在可以了.希望对您有所帮助!
Now it works. Hope that helps!
这篇关于Rails/execjs 找不到 Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!