我做了以下事情来更新我的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。)
当前回答
2018+ macOS (因为以上所有的解决方案对我来说都是失败的):
只需进入nodejs官方网站,下载官方nodejs包,双击即可安装。这是你能做的最简单、最安全、最有效的事情。
其他回答
windows操作系统请从网站下载节点可执行文件进行安装。这对我很管用。
任何操作系统(包括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的原始回答,也给它点赞)
安装nvm(卷) $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash 或与Wget $ wget - qo - https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash 显示已安装版本列表 $ NVM ls 显示可安装的版本列表 $ NVM ls-remote 安装您喜欢的版本 $ NVM安装v7.5.0 将此版本设置为默认版本 $ NVM别名默认v7.5.0
只需将新版本安装到当前文件夹。我从v4升级了我的。Windows版本为v6.10。
今天我在Windows Git Bash上运行:
$ npm i node -g
并得到如下输出:
> node@10.6.0 preinstall C:\Users\X\AppData\Roaming\npm\node_modules\node
> node installArchSpecificPackage
+ node-win-x64@10.6.0
added 1 package and audited 1 package in 23.368s
found 0 vulnerabilities
C:\Users\X\AppData\Roaming\npm\node -> C:\Users\X\AppData\Roaming\npm\node_modules\node\bin\node
+ node@10.6.0
added 2 packages from 1 contributor in 26.089s
更多信息请访问https://www.npmjs.com/package/node。