bash 当我运行节点时,什么也没有发生,永远一样
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24721182/
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
When I run node, nothing happens, the same with forever
提问by JVE999
I installed both node.js and forever.js and when I run them in my terminal (bash on Ubuntu 14.04), nothing happens.
我安装了 node.js 和forever.js,当我在终端(Ubuntu 14.04 上的bash)中运行它们时,没有任何反应。
So, it looks like:
所以,它看起来像:
#node
#
or
或者
#forever
#forever --help
#forever listall
#
Everything else not node-related runs fine.
其他与节点无关的一切都运行良好。
回答by JVE999
There was something wrong with apt-get
, so when installing node, it didn't actually install node, but it did put a program in the path that did seemingly nothing.
有问题apt-get
,所以在安装 node 时,它实际上并没有安装 node,但它确实在路径中放置了一个看似什么都没做的程序。
I uninstalled it with
我卸载了它
apt-get purge node
apt-get purge node
Then, I downloaded the 64-bit linux binary from here: http://nodejs.org/download/
然后,我从这里下载了 64 位 linux 二进制文件:http: //nodejs.org/download/
And I extracted it with tar -xvf filename
, then I set that directory/bin
to the path with:
我用 提取它tar -xvf filename
,然后我将它设置directory/bin
为路径:
PATH=$PATH:/directory/to/node/bin
PATH=$PATH:/directory/to/node/bin
And now it works fine. The forever issue was because the node installed wasn't node at all, but instead a 30kb program of some sort, I don't know.
现在它工作正常。永远的问题是因为安装的节点根本不是节点,而是某种 30kb 的程序,我不知道。
Here's the information about the program that was installed via apt-get install node
:
以下是有关通过apt-get install node
以下方式安装的程序的信息:
Package: node
Priority: optional
Section: universe/hamradio
Installed-Size: 38
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian Hamradio Maintainers <[email protected]>
Architecture: all
Version: 0.3.2-7.4
Depends: ax25-node
Conflicts: nodejs-legacy
Filename: pool/universe/n/node/node_0.3.2-7.4_all.deb
Size: 1284
MD5sum: 7385a0f5916e03d9143459ca4706f0ec
SHA1: bf7aa087db81475636897ff39de344754ce1415b
SHA256: 9756770f771bcc4183cffa622f89e21a585be96bd4de27024b0a7cb167f310ad
Description-en: Amateur Packet Radio Node program (transitional package)
The existing node package has been renamed to ax25-node. This transitional
package exists to ease the upgrade path for existing users.
Description-md5: 1278ed271672fd829c99361f93f468da
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
So, I also found that the correct way to install node
with apt-get
is apt-get install nodejs
.
所以,我也发现,安装正确的方式node
与apt-get
是apt-get install nodejs
。
回答by Scott Stafford
I had the same issue, and I think it was caused because I naively apt-get installed node first. Doing a
我遇到了同样的问题,我认为这是因为我先天真地 apt-get 安装了节点。做一个
sudo apt-get purge node
Followed by the instructions on the web here (https://github.com/nodesource/distributions):
后面是网上的说明(https://github.com/nodesource/distributions):
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
fixed the issue for me. node
doesn't exist, but nodejs
does and other tools work (like slap
) now.
为我解决了这个问题。 node
不存在,但现在nodejs
和其他工具一起工作(如slap
)。
EDIT: On one server I updated, node didexist. Not sure exactly what order things need to happen in, but whatever...
编辑:在我更新的一台服务器上,节点确实存在。不确定事情需要按什么顺序发生,但无论如何......
回答by rydrman
I was having this issue, I found that to solve the issue, I needed to remove the node file within /usr/sbin/node (found with which node
) and replace it with a hard link to /usr/bin/nodejs (found with which nodejs
)
我遇到了这个问题,我发现要解决这个问题,我需要删除 /usr/sbin/node 中的节点文件(用 找到which node
)并将其替换为指向 /usr/bin/nodejs 的硬链接(用 找到which nodejs
)
ln /usr/bin/nodejs /usr/sbin/node
ln /usr/bin/nodejs /usr/sbin/node
回答by Avinash Raj
Just run nodejs
command on your terminal after installing nodejs package.
nodejs
安装 nodejs 包后,只需在终端上运行命令。
It will give you the JavaScript prompt or interpreter.
它将为您提供 JavaScript 提示或解释器。
回答by Marek
The problem you are having is that apt-get installed NodeJS under the binary nodejs. Also when you do a npm install forever -g it also expects the binary to be node.
您遇到的问题是 apt-get 在二进制 nodejs 下安装了 NodeJS。此外,当您永远执行 npm install -g 时,它还希望二进制文件为 node.js。
To verify this you can do a
要验证这一点,您可以执行以下操作
% which forever
lrwxrwxrwx 1 root root 39 Jan 25 21:34 /usr/local/bin/forever -> ../lib/node_modules/forever/bin/forever
% which永远
lrwxrwxrwx 1 root root 39 Jan 25 21:34 /usr/local/bin/forever -> ../lib/node_modules/forever/bin/forever
to find the location of the forever script. Then check the node binary it's trying to execute.
找到永久脚本的位置。然后检查它试图执行的节点二进制文件。
% vim /usr/local/lib/node_modules/forever/bin/forever
#!/usr/bin/env node
% vim /usr/local/lib/node_modules/forever/bin/forever
#!/usr/bin/env node
This /usr/bin/env node needs to be changed to /usr/bin/env nodejs.
这个/usr/bin/env节点需要改成/usr/bin/env nodejs。
But to bypass this problem you should definitely look into using upstart. http://howtonode.org/deploying-node-upstart-monit
但是要绕过这个问题,你绝对应该考虑使用 upstart。 http://howtonode.org/deploying-node-upstart-monit