我如何更新 npm?

我如何更新 npm?

我正在尝试安装 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

相关内容