Home > Web Front-end > JS Tutorial > Let's talk about npm configuration of domestic mirrors (Taobao mirrors)

Let's talk about npm configuration of domestic mirrors (Taobao mirrors)

青灯夜游
Release: 2022-08-09 13:33:00
forward
3000 people have browsed it

npm is the package management tool for the node.js library. Because the mirror address is abroad, the installation of the library will be slow. You can change the mirror address to a domestic address (Taobao mirror) to improve the speed of installing the library.

The Taobao NPM mirror site has officially been in service to the outside world since 2014. At the beginning, it was simply intended to be a Chinese mirror site for NPM and give back to the domestic front-end community. Unknowingly, it has been running until now. At that time, referring to the Ruby Gems Taobao mirror method, we applied for the second-level domain name of taobao.org with the Alibaba open source organization. The name of the mirror site was naturally named Taobao NPM mirror site (hereinafter referred to as CNPM).

Lets talk about npm configuration of domestic mirrors (Taobao mirrors)

As shown above, from 2014 when CNPM officially provided services to today, the number of NPM packages has increased from 100,000 to 1.78 million, and the number of CNPM package downloads has increased from 100 million to 20 billion. , this is only the volume of CDN return to the origin site, the actual download volume is even more.

It can be said without humility that CNPM has witnessed the vigorous development of the domestic front-end in the past 8 years. In the future, we hope to continue to accompany China's front-end developers.

PS: Although most of the core participants are from major domestic manufacturers, CNPM itself is a neutral public welfare project, and the huge daily operation and maintenance costs come from community donations.

npm settings and configuration domestic mirror (Taobao mirror)

Lets talk about npm configuration of domestic mirrors (Taobao mirrors)

http://npm .taobao.org and http://registry.npm.taobao.org will be officially offline and stop DNS resolution on 2022.06.30.

The new domain name is npmmirror.com. For related service domain name switching rules, please refer to:

http://npm.taobao.org => http://npmmirror.com
http://registry.npm.taobao.org => http://registry.npmmirror.com
Copy after login

Modify npm to the new Taobao mirror Source:

npm config set registry http://registry.npmmirror.com
Copy after login

Need to unmirror and restore to the official source:

npm config set registry https://registry.npmjs.org
Copy after login

Check whether the npm source address has been successfully changed:

npm config get registry
Copy after login

Configure the Taobao image and install it using cnpm

npm install -g cnpm --registry=https://registry.npmmirror.com
Copy after login

It is recommended that this method will not affect the npm command and do not need to write the Taobao address every time to depend on the package. Install.

  • cnpm installation mode

When cnpm is installed, everything will be installed from the registry set here, that is, https://registry.npmmirror.com module.

When you find that the installed modules have not been synchronized during installation, Taobao NPM will automatically synchronize in the background and let you install it from the official NPM registry.npmjs.org. Next time you install this module, it will be installed directly from Taobao NPM.

  • Using cnpm

cnpm install xxx
Copy after login

For more node-related knowledge, please visit: nodejs tutorial!

The above is the detailed content of Let's talk about npm configuration of domestic mirrors (Taobao mirrors). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template