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

▼魔方 西西 提交于 2019-12-17 17:25:28

问题


I have installed nodejs using:

apt-get install nodejs

Then i have installed npm using:

apt-get install npm

And then i have installed forever using:

npm install forever -g

Now i go to my project /var/www/myproject

and attempt to run 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?


回答1:


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




回答2:


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




回答3:


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


来源:https://stackoverflow.com/questions/30281057/node-forever-usr-bin-env-node-no-such-file-or-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!