Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

javascript - ubuntu 12.04上的nodejs vs node(nodejs vs node on ubuntu 12.04)

I installed nodejs on ubuntu from instructions given here(我在这里给出的指令上安装了ubuntu上的nodejs)

When I write node --version in the terminal I see this :(当我在终端中编写node --version时,我看到:)
-bash: /usr/sbin/node: No such file or directory I can see node in the /usr/sbin/ directory, though.(不过,我可以在/usr/sbin/目录中看到节点。) Writing npm --version shows 1.3.5(写npm --version显示1.3.5)
Writing nodejs --version shows v0.10.15(编写nodejs --version显示v0.10.15) Also, I can see node in the /usr/bin/ directory.(另外,我可以在/usr/bin/目录中看到节点。) So, how do I get node working?(那么,我如何让node工作?) Also, If I use zsh instead of bash, then node command works.(此外,如果我使用zsh而不是bash,则node命令有效。)   ask by Jatin translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to manually create a symlink /usr/bin/node .(您需要手动创建符号链接/usr/bin/node 。)

Shortcut for bash compatible shells:(bash兼容shell的快捷方式:) sudo ln -s `which nodejs` /usr/bin/node Or if you use non-standard shells, just hardcode the path you find with which nodejs :(或者,如果您使用非标准shell,只需使用which nodejs对您找到的路径进行硬编码:) sudo ln -s /usr/bin/nodejs /usr/bin/node Later edit(稍后编辑) I found this explanation in the link you posted(我在你发布的链接中找到了这个解释) 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.(与节点包(业余分组无线电节点程序)存在命名冲突,并且nodejs二进制文件已从节点重命名为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.(您需要将/ usr / bin / node符号链接到/ usr / bin / nodejs,或者您可以卸载业余数据包无线电节点程序以避免这种冲突。) Later later edit(稍后编辑) 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:(虽然我在这里发布的解决方案多次为我工作,但用户在评论中报告了更多解决方案:) From @user229115(来自@ user229115) sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10 From AskUbuntu (user leftium)(来自AskUbuntu(用户leftium)) sudo apt-get --purge remove node sudo apt-get --purge remove nodejs sudo apt-get install nodejs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...