如何更新 npm [英] How to update npm
问题描述
我正在尝试安装 mean.io 样板.运行 sudo npm install -g meanio@latest
时失败.在失败之前,它指出它想要"npm 版本 1.4.x,而我安装的是 1.2.18.所以我尝试将 npm 更新到最新版本;几种方式.最后一个是...
I'm trying to install mean.io boilerplate. It fails when running sudo npm install -g meanio@latest
. Prior to failing it notes that it 'wants' npm version 1.4.x, whereas I have 1.2.18 installed. So I tried updating npm to the latest; several ways. Last of which was...
ubuntu@ip-xxx-xx-xx-xxx:~$ sudo npm install -g npm
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@1.4.7 /usr/local/lib/node_modules/npm
ubuntu@ip-xxx-xx-xx-xxx:~$ npm --version
1.2.18
为什么我刚更新到 1.4.7 时还显示 1.2.18 版本?
Why is it still showing version 1.2.18, when I just updated to 1.4.7?
推荐答案
这将使用 npm 本身更新 npm:
This will update npm using npm itself:
sudo npm install npm -g
如果卡住了,试试sudo npm update npm -g
.所有功劳都归功于 Tim Castelijns.我已经在 ubuntu 14.04、npm 1.3.10
If you are stuck, try sudo npm update npm -g
. All credit goes to Tim Castelijns. I have tested it on ubuntu 14.04, npm 1.3.10
请注意,如果您使用 nvm 来管理本地开发环境中的多个版本,例如测试目的,您所有已安装的版本(由 nvm ls
列出)都在 ~/.nvm 中,因此您只需省略系统范围的安装(即省略 sudo):
Note that if you are using nvm for managing multiple versions in your local dev environment for e.g. testing purposes, all your installed versions (listed by nvm ls
) are in ~/.nvm, hence you just omit system wide installation (i.e. omit sudo):
npm install npm -g
<小时>
DEBIAN 企业
对于完整的企业实践,请考虑 nodesource.com:
For full enterprise practice consider nodesource.com:
curl -sL https://deb.nodesource.com/setup |须藤 bash -
curl -sL https://deb.nodesource.com/setup | sudo bash -
如此处所述.
其他企业
对于非 debian 发行版,请查看节点 github wikihttps://github.com/joyent/node/wiki/installing-node.js-via-package-manager 下载页面 https://nodejs.org/en/download/
For non-debian distributions check out on the node github wiki
https://github.com/joyent/node/wiki/installing-node.js-via-package-manager download page https://nodejs.org/en/download/
对于历史理解:Chis Lea 一直在维护他的 PPA,但现在 加入了力量 与 nodesource.
For historical understanding: Chis Lea was maintaining his PPA but now joined forces with nodesource.
这篇关于如何更新 npm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!