node.js和node有什么区别? [英] What are the differences between node.js and node?
问题描述
我已经在计算机上安装了node.js(Linux Mint 15),当我运行node example.js
时,它说:
I've installed node.js in my machine (linux mint 15), when I run node example.js
, it says:
The program 'node' can be found in the following packages:
* node
* nodejs-legacy
Try: sudo apt-get install <selected package>
那么node和nodejs有什么区别?我之前已经安装了node.js和node,但是当我运行node example.js
时,Web服务器根本无法启动.因此,我删除了node并保留了node.js.
So what are the differences between node and nodejs? I had both node.js and node installed previously, but when I run node example.js
, the web server doesn't start at all. So I deleted node and kept node.js.
推荐答案
包节点与node.js不相关.
The package node is not related to node.js.
nodejs
是您想要的,但是可以说最好将该命令称为node以便与使用#!/usr/bin/env node
的脚本兼容.
nodejs
is what you want, however it is arguably better to have the command be called node for compatibility with scripts that use #!/usr/bin/env node
.
您可以只在路径中创建符号链接:
You can either just create a symlink in your path:
sudo ln -s `which nodejs` /usr/local/bin/node
或者您可以安装nvm ,然后使用它来安装最新版本的node.js:>
Or you could install nvm and then use it to install the latest version of node.js:
nvm install stable
我更喜欢nvm方法,因为它允许您sudo apt-get remove nodejs
,然后管理您自己使用的节点版本.您还可以安装多个版本的node.js,并使用nvm use
轻松地在它们之间切换.
I prefer the nvm method, as it allows you to sudo apt-get remove nodejs
, and then manage which version of node you're using yourself. You can also have multiple versions of node.js installed and use nvm use
to easily switch between them.
我还喜欢在.bashrc
的底部添加一行,例如:nvm use stable > /dev/null
.这将自动使用您已安装的最新版本.
I also like to add a line to the bottom my .bashrc
like: nvm use stable > /dev/null
. That will automatically use the latest version you have installed.
要将节点版本更新到最新的稳定版,请执行以下操作:nvm install stable
.每次执行此操作时,如果要继续使用它们,都将需要安装全局安装的所有npm软件包.
To update your node version to the latest stable: nvm install stable
. Every time you do this you will need to install any npm packages that you had installed globally if you want to continue using them.
要切换到旧版本,只需运行nvm use <version>
,或者,如果尚未安装旧版本,请运行:nvm install <version>
.
To switch to an old version just run nvm use <version>
, or, if you don't have the old version installed already: nvm install <version>
.
这篇关于node.js和node有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!