uglifier gem load error / download node.js?

我开始使用Ruby on Rails,并遵循InstallRails中的步骤…我在桌面上创build了sample_app,现在我无法创build服务器。

我的命令

$ rails server 

回答如下

 ...There was an error while trying to load the gem 'uglifier'. etc 

我已经在这里和其他地方读过几个线程,比如这个和这个 …在后者中似乎有一个解决scheme,我不明白….我不能下载node.js! 或nodejs? 我的命令和目录在Gitbash下载它是什么?

它需要JS运行时。 只需安装JS运行时的gem therubyracer 。 在默认轨道Gemfile中,取消注释gem'therubyracer'的注释掉的行。如果你没有find它,把gem添加到你的Gemfile中

 gem 'therubyracer' 

然后运行

 bundle install 

gem将被安装,它应该工作。

否则,你可以安装node.js.

对于Ubuntu

 sudo apt-get install nodejs 

对于Mac

 brew install nodejs