npm Taobao mirror installation

npm Taobao mirror installation

The original Taobao npm domain name will stop parsing soon, the official link , the following command has been updated, feel free to eat.

method one:

Use the cnpm command line tool customized by Ali to replace the default npm, and enter the following code

npm install -g cnpm --registry=http://registry.npmmirror.com

Check if the installation was successful:

$ cnpm -v

After the installation is successful, the way to install dependent packages in the future is the same as that of npm, except that the npm command can be replaced with cnpm.

Method Two:

a:Single use:

npm install --registry=http://registry.npmmirror.com

b: permanent replacement:

When developing react-native, do not use cnpm. The module path installed by cnpm is strange, and the packager cannot recognize it normally.

Therefore, in order to facilitate development, we'd better use Taobao's mirror source directly and permanently

Direct command-line settings

$ npm config set registry http://registry.npmmirror.com

Modify settings manually

1.打开.npmrc文件(C:\Program Files\nodejs\node_modules\npm\npmrc,没有的话可以使用git命令行建一个( touch .npmrc),用cmd命令建会报错)
 2.增加 registry =http://registry.npmmirror.com  即可。

If you need to restore to the original official address, you only need to execute the following command:

npm config set registry https://registry.npmjs.org

Check if the installation is successful:

npm config get registry

Guess you like

Origin blog.csdn.net/qq_53729147/article/details/127962271