![我如何更新 npm?](https://linux22.com/image/987979/%E6%88%91%E5%A6%82%E4%BD%95%E6%9B%B4%E6%96%B0%20npm%EF%BC%9F.png)
我正在尝试安装 Yeoman,以便可以安装 AngularJS,但是遇到了与 npm 版本有关的问题。运行时的输出如下npm install -g yo
:
npm WARN deprecated [email protected]: this package has been reintegrated into npm and is now out of date with respect to npm
/home/marieficid/.node/bin/yo -> /home/marieficid/.node/lib/node_modules/yo/lib/cli.js
> [email protected] postinstall /home/marieficid/.node/lib/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✖ Node.js version
Your Node.js version is outdated.
Upgrade to the latest version: https://nodejs.org
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✖ npm version
Your npm version is outdated.
Upgrade to the latest version by running:
npm install -g npm
✔ NODE_PATH matches the npm root
Found potential issues on your machine :(
/home/marieficid/.node/lib
└── [email protected]
这是我运行时的输出npm install -g npm@latest
(我当前的版本是 3.7.3):
/home/marieficid/.node/bin/npm -> /home/marieficid/.node/lib/node_modules/npm/bin/npm-cli.js
/home/marieficid/.node/lib
└── [email protected]
有人知道如何解决这个问题吗?
编辑:运行sudo npm --version
返回 2.14.12 而不是 3.7.3。
答案1
您的主文件夹中很可能有一个.npmrc
包含prefix
变量的文件。
如果是这种情况,您将必须更新 $PATH 变量并添加新的 bin 路径,在您的情况下$HOME/.node/bin/
,还要确保它位于 npm 当前所在的路径之后,您可以使用来找出这一点which npm
。要设置您的路径变量:什么是 PATH 环境变量以及如何添加它?和https://help.ubuntu.com/community/EnvironmentVariables