我做了以下事情来更新我的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。)
当前回答
一些Linux发行版,如Arch Linux,在它们的包存储库中有Node.js。在这样的系统上,最好使用标准的包更新过程,如pacman -Suy或类似的apt-get或yum命令。
截至目前(2016年11月),EPEL7提供了一个相当最新的Node.js版本(6.9.1,这是Node.js主页上提供的最新LTS版本)。所以在CentOS 7和衍生产品上,你可以通过yum install EPEL -release和yum install nodejs来添加EPEL存储库。
CentOS 6/EPEL6有0.10。x自2016年10月以来不支持上游。
其他回答
$ npm install -g npm stable
我负责更新NPM
根据Nodejs官方页面,您可以使用Chocolatey或Scoop在windows上安装和更新新的节点版本
使用(巧克力色):
cinst nodejs
# or for full install with npm
cinst nodejs.install
使用(独家):
scoop install nodejs
你也可以直接从nodejs.org网站下载Windows安装程序
你可以使用nvm。
在http://nodejs.org/上查看最新版本(例如v0.10.26) 执行nvm install v0.10.26命令
完成了。
你可以选择运行哪个版本:
NVM ls列出可用的版本,并告诉您现在正在使用哪个版本。
将当前节点修改为所请求的版本。
nvm alias default VERSION设置默认版本。下次你源nvm.sh时,这将是加载的版本(注意,它不会改变当前使用的版本,为此运行nvm use)。
所有你需要更新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的原始回答,也给它点赞)