永远的节点 /usr/bin/env: 节点: 没有那个文件或目录

Node forever /usr/bin/env: node: No such file or directory

我安装了 nodejs 使用:

apt-get install nodejs

然后我安装了 npm 使用:

apt-get install npm

然后我安装了永久使用:

npm install forever -g

现在我去我的项目/var/www/myproject

并尝试 运行 forever start server.js

然后我收到以下消息:

/usr/bin/env: node: No such file or directory

谁能告诉我这是怎么回事?

编辑:自 2018 年 12 月起,这不再是正确的方法。见其他两个答案。

您需要将 nodejs 可执行文件符号链接到节点 sudo ln -s "$(which nodejs)" /usr/local/bin/node 这样做的原因是当您这样做时 "apt-get install node",它会安装一个不相关的包,所以他们不得不选择一个不同的名称,所以它不会冲突

最好更新到最新的节点版本

  1. sudo npm 缓存清理 -f
  2. sudo npm install -g n
  3. sudo n 稳定

虽然接受的答案解决了问题,但正确的方法是安装 nodejs,至少对于 Debian Jessie 和 forward 以及 Ubuntu 14.4 和 forward1 -遗产:

apt-get install nodejs-legacy

原因是Debian已经有一个包(节点)提供/usr/bin/node,而nodejs node二进制文件有将安装到 /usr/bin/nodejs.

nodejs-legacy 包提供了从 /usr/bin/nodejs 到 /usr/bin/node 的符号 link(并且与 节点包)。

来源:[CTTE #614907] Resolution of node/nodejs conflict and Debian bug #614907: node: name conflicts with node.js interpreter