node.js 节点永远 /usr/bin/env: node: 没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30281057/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Node forever /usr/bin/env: node: No such file or directory
提问by Marc Rasmussen
I have installed nodejs using:
我已经使用以下方法安装了 nodejs:
apt-get install nodejs
Then i have installed npm using:
然后我使用以下方法安装了 npm:
apt-get install npm
And then i have installed forever using:
然后我使用以下方法永久安装:
npm install forever -g
Now i go to my project /var/www/myproject
现在我去我的项目 /var/www/myproject
and attempt to run forever start server.js
并尝试运行 forever start server.js
then i get the following message:
然后我收到以下消息:
/usr/bin/env: node: No such file or directory
Can anyone tell me whats going on?
谁能告诉我这是怎么回事?
回答by chedabob
EDIT: As of December 2018, this is no longer the correct way. See the other two answers.
编辑:截至 2018 年 12 月,这不再是正确的方法。请参阅其他两个答案。
You need to symlink the nodejs executable to node
sudo ln -s "$(which nodejs)" /usr/local/bin/nodeThe reason for this is that when you do "apt-get install node", it installs an unrelated package, so they had to choose a different name so it wouldn't conflict
您需要将 nodejs 可执行文件符号链接到 node
sudo ln -s "$(which nodejs)" /usr/local/bin/node原因是当您执行“apt-get install node”时,它会安装一个不相关的包,因此他们必须选择不同的名称,以免发生冲突
回答by Clément Schreiner
While the accepted answer fixes the problem, the correct way to do that, at least with Debian Jessie and forward and Ubuntu 14.4 and forward1is to install nodejs-legacy:
虽然接受的答案解决了问题,但正确的方法是安装nodejs-legacy,至少对于 Debian Jessie 和 forward 以及 Ubuntu 14.4 和 forward 1:
apt-get install nodejs-legacy
The reason is that Debian already had a package (node) providing /usr/bin/node, and the nodejs nodebinary had to be installed into /usr/bin/nodejs.
原因是 Debian 已经有一个提供/usr/bin/node的包(节点),并且必须将 nodejs节点二进制文件安装到 /usr/bin/nodejs 中。
The nodejs-legacypackage provides a symbolic link from /usr/bin/nodejs to /usr/bin/node (and conflicts with the nodepackage).
所述的NodeJS遗留包提供从/ usr /斌/的NodeJS到/ usr /斌/节点(以及与冲突的符号链接节点包)。
Source: [CTTE #614907] Resolution of node/nodejs conflictand Debian bug #614907: node: name conflicts with node.js interpreter
来源:[CTTE #614907] 解决节点/nodejs 冲突和Debian 错误 #614907:节点:名称与 node.js 解释器冲突
回答by Shantanu
It's better if you update to the latest node version
如果你更新到最新的节点版本会更好
- sudo npm cache clean -f
- sudo npm install -g n
- sudo n stable
- 须藤 npm 缓存清洁 -f
- 须藤 npm install -gn
- 须藤稳定

