Rails / execjs找不到Node.js [英] Node.js not found by Rails / execjs

查看:748
本文介绍了Rails / execjs找不到Node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过从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 app(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,并将runtime命令更改为精确的安装路径。

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。其中I

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和source的问题也有类似的问题。它已经成功安装,但我一直无法编译我的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]#make install

...

安装/usr/local/lib/node_modules/npm/html/doc/folders.html

symlinking ../lib /node_modules/npm/bin/npm-cli.js - > / usr / local / bin / npmogle
将/ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆