- 如何更新 NodeJS 和 NPM 到下一个版本？
I just installed
npm(for additional modules).
How can I update Node.js and the modules which I'm using to the latest versions?
npmdo it, or do I have to remove and reinstall Node.js and npm to get the next versions?
I followed this steps in the
As you may know, NPM is currently bundled with Node.js, it means that if you have installed
node you already have installed
npm. There are several approaches to keep up to date the Node.js and NPM, you need to use one of the following version managers:
If yo are on Mac, you can use Homebrew. To install NodeJS and NPM using brew:
$ brew install node
later you will be able to update it using
$ brew update && brew upgrade node
NPM will be updated as well.
You also will be able to
switch to the one of the previous versions if you need, for example:
$ brew switch node 0.10.26
To install brew to your Mac:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
n is most likely to
rvm (Ruby Version Manager), and can be used to manage and update
Install Node.js versions easily:
$ n 0.10.26 $ n 0.8.17 $ n 0.9.6
Use (and install if missing) the latest official release:
$ n latest
Use/install the stable official release:
$ n stable
Switch to the previous version you were using:
$ n prev
If you want to see the list of installed nodes, just run
n from your command line, the output will be something like the following:
$ n 0.10.26 • 0.8.17 0.9.6
The dot (•) means that it's a currently active version. To select a node version from the list use
down arrows and activate using
n package is written on pure
linux shell and available as a npm module (contains
package.json), so if you have any Node.js installed, you can install/update the
n through the
$ npm install -g n
nvm is also like
RVM, even the command names and usage are very similar.
To download, compile, and install the latest v0.10.x release of the Node.js using
$ nvm install 0.10
And then you can switch to the installed version:
$ nvm use 0.10
You can create an
.nvmrc file containing version number in the project root folder; then run the following command to switch to the specified version:
$ nvm use
Or you can just run it:
$ nvm run 0.10
If you want to see which versions are already installed, use:
$ nvm ls
nvm itself you can use the install script (requires
$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
All these approaches I've used on MacOSX and Linux, I don't have any experience on how to manage Node.js versions on Windows, I can only suppose that the
n (the second one) will work for Microsoft's OS (at least from the
See the docs for the
npm update [<name> [<name> ...]]
This command will update all the packages listed to the latest version (specified by the tag config). It will also install missing packages.
Additionally, see the FAQ:
How do I update npm?
npm install -g npm
Please note that this command will remove your current version of npm. Make sure to use
sudo npm install -g npmif on a Mac.
You can also update all outdated local packages by doing
npm updatewithout any arguments, or global packages by doing
npm update -g.
Occasionally, the version of npm will progress such that the current version cannot be properly installed with the version that you have installed already. (Consider, if there is ever a bug in the update command.) In those cases, you can do this:
curl https://www.npmjs.com/install.sh | sh
To update Node.js itself, I recommend you use nvm, the Node Version Manager.
Updating npm is easy:
npm install npm@latest -g
I understand this question is for Linux machine but just in case anybody is looking for a Windows solution, just go to the Node.js site, click the download button on the homepage and execute the installer program.
Thankfully it took care of everything and with a few clicks of 'Next' button I got the latest 0.8.15 Node.js version running on my Windows 7 machine.
$ npm install -g npm stable
Worked for me to update from 1.4.28 to 2.1.5
Just listened to an interview with the npm team on the latest episode of nodeup, and they recommended not using
update for the update from
2.x. Instead, use:
npm install npm -g
Use n module from npm in order to upgrade node . n is a node helper package that installs or updates a given node.js version.
sudo npm cache clean -f sudo npm install -g n sudo n stable sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs
NOTE that the default installation for nodejs is in the /usr/bin/nodejs and not /usr/bin/node
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node sudo n rm 6.0.0 # replace number with version of Node that was installed sudo npm uninstall -g n
If you get the following error
bash: /usr/bin/node: No such file or directory then the path you have entered at
sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs
if wrong. so make sure to check if the update nodejs has been installed at the above path and the version you are entered is correct.
I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new one.
Install npm =>
sudo apt-get install npm
Install n =>
sudo npm install n -g
latest version of node =>
sudo n latest
Specific version of node you can
List available node versions =>
Install a specific version =>
sudo n 4.5.0
For Cygwin users:
Installing n (node version manager) in
Cygwin doesn't work, instead update node with:
wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\pathto\nodejs\node.exe' # Updating npm npm i -g npm
Yes, you need to install
- 学院 Windows版YOLOv4目标检测实战：训练自己的数据集
- 下载 2019数学建模历年题目及优秀论文
- 下载 华为海思数字IC提前批笔试题目，2020届华为海思校园招聘，西南地区
- 博客 Java基础知识面试题（2020最新版）
- 学院 三个项目玩转深度学习（附1G源码）
- 学院 软件测试2小时入门
- 学院 Python数据分析与挖掘
- 博客 【大总结2】大学两年，写了这篇几十万字的干货总结
- 博客 阿里巴巴高级面试题（首发、高频136道、含答案）
- 下载 LINGO20200701.zip
- 博客 oracle学习第三天
- 下载 2020联发科笔试题（IC方向）b.docx
- 学院 使用TensorFlow+keras快速构建图像分类模型
- 博客 点进来看看，为什么要学习【数据结构与算法】？ 该如何学习？
- 博客 《三天给你聊清楚redis》第2天看看redis怎么被搞出来的（22036字）
- 下载 中国全国省地县乡村五级地标kmz（很准）
- 学院 R语言入门基础
- 学院 玩转Linux：常用命令实例指南
- 博客 利用 Python 爬取了 13966 条运维招聘信息，我得出了哪些结论？
- 下载 2018年数学建模国赛A题matlab代码及注释.rar
- 学院 微信公众平台开发入门
- 学院 实用主义学Python（小白也容易上手的Python实用案例）
- 学院 Python+OpenCV计算机视觉
- 下载 2020联发科笔试题（IC方向)a.docx
- 博客 Python代码实现飞机大战
- 下载 linux下利用/proc进行进程树的打印