Node forever/usr/bin/env: Node: 没有这样的文件或目录

我安装 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

有人能告诉我发生了什么吗?

94578 次浏览

EDIT: As of December 2018, this is no longer the correct way. See the other two answers.

You need to symlink the nodejs executable to node sudo ln -s "$(which nodejs)" /usr/local/bin/node The 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

It's better if you update to the latest node version

  1. sudo npm cache clean -f
  2. sudo npm install -g n
  3. sudo n stable

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 forward1 is to install nodejs-legacy:

apt-get install nodejs-legacy

The reason is that Debian already had a package (node) providing /usr/bin/node, and the nodejs node binary had to be installed into /usr/bin/nodejs.

The nodejs-legacy package provides a symbolic link from /usr/bin/nodejs to /usr/bin/node (and conflicts with the node package).

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