我做了以下事情来更新我的npm:
npm update npm -g
但是我不知道如何更新Node.js。有什么建议吗?(我使用Node.js 0.4.1,想更新到Node.js 0.6.1。)
我做了以下事情来更新我的npm:
npm update npm -g
但是我不知道如何更新Node.js。有什么建议吗?(我使用Node.js 0.4.1,想更新到Node.js 0.6.1。)
当前回答
所有你需要更新Node.js的版本:
$ brew install node
如果你没有自制啤酒;请登录http://brew.sh/。
其他回答
任何操作系统(包括Windows, Mac和Linux)
2022年10月更新
只需进入Node.js官方网站(nodejs.org),下载并执行安装程序。
它会处理好所有的事情,只需点击几下“Next”,你就可以在你的机器上运行最新的Node.js版本。自2020年以来,它是更新NodeJS的推荐方式。这是最简单、最不令人沮丧的解决方案。
专业提示
NodeJS installation includes NPM (Node package manager). To check your NPM version use npm version or node --version. If you prefer CLI, to update NPM use npm install -g npm and then npm install -g node. For more details, see the docs for install command. Keep an eye on NodeJS blog - Vulnerabilities so you don't miss important security releases. Keep your NodeJS up-to-date. Operating systems supported by Node.js: Windows, Linux, MacOS, IBM AIX. For Docker users, here's the official Node.js image. For more information on installing Node.js on a variety of less-common operating systems, see this page (there's even Node for Android!). Troubleshooting for Windows: If anyone gets file error 2502/2503 like myself during install, run the .msi via Administrator command prompt with command msiexec /package [node msi]
如果我的回答有用,别忘了给它投票 (这里是Anmol Saraf的原始回答,也给它点赞)
第一次更新npm,
NPM install -g
然后更新节点,
NPM install -g node或NPM install -g n
版本安装后检查
Node——version或Node -v
正如你们中的一些人已经说过的,最简单的方法是通过Node.js包管理器npm更新Node.js。如果你是一个Linux用户(在我的情况下是基于debian的),我建议将这些行添加到你的.bashrc文件(在主目录下):
function nodejsupdate() {
ARGC=$#
version=latest
if [ $ARGC != 0 ]; then
version=$1
fi
sudo npm cache clean -f
sudo npm install -g n
sudo n $version
}
保存后重新启动终端,并写入nodejsupdate更新到Node.js的最新版本或nodejsupdate v6.0.0(例如)更新到Node.js的特定版本。
奖励:更新npm(将这些行添加到.bashrc)
function npmupdate() {
sudo npm i npm -g
}
重新启动终端后,编写npmupdate将节点包管理器更新到最新版本。
现在你可以通过你的终端更新Node.js和npm(更容易)。
升级节点到最新版本或指定版本,您可以执行以下操作:
sudo npm install n -g
sudo n 0.10.18 // This will give you the specific version
对于最新的稳定版本:
sudo n stable
对于最新的LTS版本(在Mac上测试)
sudo n lts
Ubuntu的:
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs
来源:https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version