更新时间:2023-12-04 12:05:22
包节点与node.js无关.
The package node is not related to node.js.
nodejs
是您想要的,但是为了与使用 #!/usr/bin/env node
的脚本兼容,将命令称为 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 <version>
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
,或者,如果您尚未安装旧版本:nvm install
代码>.
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>
.