Rails -找不到JavaScript运行时?

时间:2021-11-28 17:08:06

I created a new Rails project using rails 3.1.0.rc4 on my local machine but when I try to start the server I get: Could not find a JavaScript runtime. See here for a list of available runtimes. (ExecJS::RuntimeUnavailable)

我使用Rails 3.1.0创建了一个新的Rails项目。rc4在本地机器上,但当我尝试启动服务器时,我得到:找不到JavaScript运行时。请参阅这里的可用运行时列表。(ExecJS::RuntimeUnavailable)

Note: This is not about Heroku.

注意:这不是关于Heroku。

11 个解决方案

#1


434  

Installing a javascript runtime library such as nodejs solves this

To install nodejs on ubuntu, you can type the following command in the terminal:

要在ubuntu上安装nodejs,可以在终端输入以下命令:

sudo apt-get install nodejs

To install nodejs on systems using yum, type the following in the terminal:

要在系统上安装nodejs,请在终端输入以下内容:

yum -y install nodejs

#2


43  

Note from Michael 12/28/2011 - I have changed my accept from this (rubytheracer) to above (nodejs) as therubyracer has code size issues. Heroku now strongly discourage it. It will 'work' but may have size/performance issues.

从Michael 12/28/2011 -我已经改变了我的接受(rubytheracer)到上面(nodejs),因为therubyracer有代码大小问题。Heroku现在强烈反对。它将“工作”,但可能有规模/性能问题。

If you add a runtime, such as therubyracer to your Gemfile and run bundle then try and start the server it should work.

如果您添加一个运行时,比如您的Gemfile和run bundle的therubyracer,那么尝试启动它应该工作的服务器。

gem 'therubyracer'

A javascript runtime is required for compiling coffeescript and also for uglifier.

编写coffeescript和uglifier时需要一个javascript运行时。

Update, 12/12/2011: Some folks found issues with rubytheracer (I think it was mostly code size). They found execjs (or nodejs) worked just as well (if not better) and were much smaller.

更新,12/12/2011:一些人发现rubytheracer的问题(我认为它主要是代码大小)。他们发现,execjs(或nodejs)也同样有效(如果不是更好的话),而且要小得多。

n.b. Coffeescript became a standard for 3.1+

b. Coffeescript成为3.1+的标准。

#3


25  

Add following gems in your gem file

在gem文件中添加以下gem。

gem 'therubyracer'
gem 'execjs'

and run

和运行

bundle install

OR

Install Node.js to fix it permanently for all projects.

安装节点。js将永久地修复所有项目。

#4


15  

sudo apt-get install nodejs does not work for me. In order to get it to work, I have to do the following:

sudo apt-get安装nodejs对我不起作用。为了让它发挥作用,我必须做以下工作:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Hope this will help someone having the same problem as me.

希望这能帮助和我有同样问题的人。

#5


6  

On the windows platform, I met that problem too The solution for me is just add

在windows平台上,我遇到了这个问题,我的解决方案就是添加。

C:\Windows\System32

to the PATH

道路

and restart the computer.

并重新启动计算机。

#6


3  

I had this issue on a Windows machine and installing node.js was the solution that finally worked for me. This came after trying multiple other routes including trying to get 'therubyracer' working. Though the github for node.js suggests that installation on windows is still unstable, the website at http://nodejs.org/ had a Windows installer which worked perfectly.

我在Windows机器和安装节点上遇到了这个问题。js是最终为我工作的解决方案。这是在尝试了许多其他路线,包括试图让“therubyracer”工作之后。虽然是节点的github。js建议在windows上安装仍然是不稳定的,网址是http://nodejs.org/有一个运行完美的windows安装程序。

#7


1  

if you already install nodejs from source for example, and execjs isn't recognizing it you might want to try this tip: https://coderwall.com/p/hyjdlw

如果您已经从源代码中安装了nodejs,并且execjs没有认识到它,那么您可能想尝试一下这个技巧:https://coderwall.com/p/hyjdlw。

#8


1  

If all fails you can try

如果一切都失败了,你可以试试。

# aptitude install nodejs

#才能安装nodejs

as root. You can test your install with the following command:

作为根。您可以使用以下命令来测试您的安装:

# node -v

#节点- v

If you want to install NPM, please refer following link. Hope it helps.

如果您想要安装NPM,请参考以下链接。希望它可以帮助。

#9


0  

On CentOS 6.5, the following worked for me:

在CentOS 6.5,以下为我工作:

sudo yum install -y nodejs

#10


0  

Install a Javascript runtime

The error is caused by the absence of a Javascript runtime on your local machine. To resolve this, you'll need to install NodeJS.

错误是由于本地机器上没有Javascript运行时造成的。要解决这个问题,您需要安装node . js。

You can install NodeJS through the Node Version Manager or nvm:

您可以通过节点版本管理器或nvm安装NodeJS:

First, install nvm:

首先,安装nvm:

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash

Install Node through nvm:

通过nvm安装节点:

nvm install 5.9.1

This will install version 5.9.1 of Node.

这将安装版本5.9.1的节点。

#11


0  

I ran into this issue using Phusion Passenger (running as an nginx module) on a Redhat server. We already had a Javascript runtime installed. Other Rails apps in the same parent directory worked fine.

我在Redhat服务器上使用Phusion乘客(作为nginx模块运行)遇到了这个问题。我们已经安装了Javascript运行时。在同一父目录下的其他Rails应用程序运行良好。

It turned out that we had a permissions issue. Run "ls -l" and see if the folder has the same owner and group as other working apps on the system. I had to run chown and chgrp on the folder (with the recursive switch) to fix it.

结果是我们有权限问题。运行“ls -l”,查看该文件夹是否拥有与系统上其他工作应用程序相同的所有者和组。我必须在文件夹上运行chown和chgrp(用递归开关)来修复它。

#1


434  

Installing a javascript runtime library such as nodejs solves this

To install nodejs on ubuntu, you can type the following command in the terminal:

要在ubuntu上安装nodejs,可以在终端输入以下命令:

sudo apt-get install nodejs

To install nodejs on systems using yum, type the following in the terminal:

要在系统上安装nodejs,请在终端输入以下内容:

yum -y install nodejs

#2


43  

Note from Michael 12/28/2011 - I have changed my accept from this (rubytheracer) to above (nodejs) as therubyracer has code size issues. Heroku now strongly discourage it. It will 'work' but may have size/performance issues.

从Michael 12/28/2011 -我已经改变了我的接受(rubytheracer)到上面(nodejs),因为therubyracer有代码大小问题。Heroku现在强烈反对。它将“工作”,但可能有规模/性能问题。

If you add a runtime, such as therubyracer to your Gemfile and run bundle then try and start the server it should work.

如果您添加一个运行时,比如您的Gemfile和run bundle的therubyracer,那么尝试启动它应该工作的服务器。

gem 'therubyracer'

A javascript runtime is required for compiling coffeescript and also for uglifier.

编写coffeescript和uglifier时需要一个javascript运行时。

Update, 12/12/2011: Some folks found issues with rubytheracer (I think it was mostly code size). They found execjs (or nodejs) worked just as well (if not better) and were much smaller.

更新,12/12/2011:一些人发现rubytheracer的问题(我认为它主要是代码大小)。他们发现,execjs(或nodejs)也同样有效(如果不是更好的话),而且要小得多。

n.b. Coffeescript became a standard for 3.1+

b. Coffeescript成为3.1+的标准。

#3


25  

Add following gems in your gem file

在gem文件中添加以下gem。

gem 'therubyracer'
gem 'execjs'

and run

和运行

bundle install

OR

Install Node.js to fix it permanently for all projects.

安装节点。js将永久地修复所有项目。

#4


15  

sudo apt-get install nodejs does not work for me. In order to get it to work, I have to do the following:

sudo apt-get安装nodejs对我不起作用。为了让它发挥作用,我必须做以下工作:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Hope this will help someone having the same problem as me.

希望这能帮助和我有同样问题的人。

#5


6  

On the windows platform, I met that problem too The solution for me is just add

在windows平台上,我遇到了这个问题,我的解决方案就是添加。

C:\Windows\System32

to the PATH

道路

and restart the computer.

并重新启动计算机。

#6


3  

I had this issue on a Windows machine and installing node.js was the solution that finally worked for me. This came after trying multiple other routes including trying to get 'therubyracer' working. Though the github for node.js suggests that installation on windows is still unstable, the website at http://nodejs.org/ had a Windows installer which worked perfectly.

我在Windows机器和安装节点上遇到了这个问题。js是最终为我工作的解决方案。这是在尝试了许多其他路线,包括试图让“therubyracer”工作之后。虽然是节点的github。js建议在windows上安装仍然是不稳定的,网址是http://nodejs.org/有一个运行完美的windows安装程序。

#7


1  

if you already install nodejs from source for example, and execjs isn't recognizing it you might want to try this tip: https://coderwall.com/p/hyjdlw

如果您已经从源代码中安装了nodejs,并且execjs没有认识到它,那么您可能想尝试一下这个技巧:https://coderwall.com/p/hyjdlw。

#8


1  

If all fails you can try

如果一切都失败了,你可以试试。

# aptitude install nodejs

#才能安装nodejs

as root. You can test your install with the following command:

作为根。您可以使用以下命令来测试您的安装:

# node -v

#节点- v

If you want to install NPM, please refer following link. Hope it helps.

如果您想要安装NPM,请参考以下链接。希望它可以帮助。

#9


0  

On CentOS 6.5, the following worked for me:

在CentOS 6.5,以下为我工作:

sudo yum install -y nodejs

#10


0  

Install a Javascript runtime

The error is caused by the absence of a Javascript runtime on your local machine. To resolve this, you'll need to install NodeJS.

错误是由于本地机器上没有Javascript运行时造成的。要解决这个问题,您需要安装node . js。

You can install NodeJS through the Node Version Manager or nvm:

您可以通过节点版本管理器或nvm安装NodeJS:

First, install nvm:

首先,安装nvm:

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash

Install Node through nvm:

通过nvm安装节点:

nvm install 5.9.1

This will install version 5.9.1 of Node.

这将安装版本5.9.1的节点。

#11


0  

I ran into this issue using Phusion Passenger (running as an nginx module) on a Redhat server. We already had a Javascript runtime installed. Other Rails apps in the same parent directory worked fine.

我在Redhat服务器上使用Phusion乘客(作为nginx模块运行)遇到了这个问题。我们已经安装了Javascript运行时。在同一父目录下的其他Rails应用程序运行良好。

It turned out that we had a permissions issue. Run "ls -l" and see if the folder has the same owner and group as other working apps on the system. I had to run chown and chgrp on the folder (with the recursive switch) to fix it.

结果是我们有权限问题。运行“ls -l”,查看该文件夹是否拥有与系统上其他工作应用程序相同的所有者和组。我必须在文件夹上运行chown和chgrp(用递归开关)来修复它。