我根据 here 给出的说明在 ubuntu 上安装了 nodejs
当我在终端中写 node --version
时,我看到:
-bash:/usr/sbin/node: 没有那个文件或目录
我可以在 /usr/sbin/
目录中看到 Node 。
编写 npm --version
显示 1.3.5
编写 nodejs --version
显示 v0.10.15
另外,我可以在 /usr/bin/
目录中看到 Node 。
那么,如何让 node
工作?
另外,如果我使用 zsh 而不是 bash,那么 node
命令可以工作。
最佳答案
您需要手动创建符号链接(symbolic link)/usr/bin/node
。 bash 兼容 shell 的快捷方式:
sudo ln -s `which nodejs` /usr/bin/node
或者,如果您使用非标准 shell,只需使用 which nodejs
对您找到的路径进行硬编码:
sudo ln -s /usr/bin/nodejs /usr/bin/node
稍后编辑
我在您发布的链接中找到了这个解释
There is a naming conflict with the node package (Amateur Packet Radio Node Program), and the nodejs binary has been renamed from node to nodejs. You'll need to symlink /usr/bin/node to /usr/bin/nodejs or you could uninstall the Amateur Packet Radio Node Program to avoid that conflict.
稍后编辑
我已经有一段时间没有回答这个问题了。尽管我在这里发布的解决方案多次为我工作,但用户在评论中报告了更多解决方案:
来自@user229115
sudo update-alternatives --install/usr/bin/node node/usr/bin/nodejs 10
来自 AskUbuntu(用户 leftium)
sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs
关于javascript - ubuntu 12.04上的nodejs vs node,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18130164/