ubuntu 12.04 上的 nodejs 与 node [英] nodejs vs node on ubuntu 12.04

查看:39
本文介绍了ubuntu 12.04 上的 nodejs 与 node的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根据此处的说明在 ubuntu 上安装了 nodejs

当我在终端中编写 node --version 时,我看到:
-bash:/usr/sbin/node: 没有那个文件或目录

When I write node --version in the terminal I see this :
-bash: /usr/sbin/node: No such file or directory

不过,我可以在 /usr/sbin/ 目录中看到节点.

I can see node in the /usr/sbin/ directory, though.

编写 npm --version 显示 1.3.5
编写 nodejs --version 显示 v0.10.15

Writing npm --version shows 1.3.5
Writing nodejs --version shows v0.10.15

另外,我可以在/usr/bin/目录下看到node.

Also, I can see node in the /usr/bin/ directory.

那么,我如何让 node 工作?

So, how do I get node working?

此外,如果我使用 zsh 而不是 bash,则 node 命令有效.

Also, If I use zsh instead of bash, then node command works.

推荐答案

您需要手动创建符号链接 /usr/bin/node.bash 兼容 shell 的快捷方式:

You need to manually create a symlink /usr/bin/node. Shortcut for bash compatible shells:

sudo ln -s `which nodejs` /usr/bin/node

或者,如果您使用非标准 shell,只需使用 which nodejs 对找到的路径进行硬编码:

Or if you use non-standard shells, just hardcode the path you find with which nodejs:

sudo ln -s /usr/bin/nodejs /usr/bin/node

后期编辑

我在你发布的链接中找到了这个解释

I found this explanation in the link you posted

与node包(业余包无线电节点程序)存在命名冲突,nodejs二进制已经从node重命名为nodejs.您需要将/usr/bin/node 符号链接到/usr/bin/nodejs 或者您可以卸载 Amateur Packet Radio Node Program 以避免这种冲突.

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.

稍后编辑

我已经有一段时间没有回答这个问题了.虽然我在这里发布的解决方案对我有用过几次,但用户在评论中报告了更多的解决方案:

It's been a while since I answered this. Although the solution I posted up here worked for me several times, users have reported a few more solutions within the comments:

来自@user229115

From @user229115

sudo update-alternatives --install/usr/bin/node node/usr/bin/nodejs 10

来自 AskUbuntu(用户 leftium)

From AskUbuntu (user leftium)

sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs

这篇关于ubuntu 12.04 上的 nodejs 与 node的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆