In the production environment, do you use more cnpm or npm, in China?

applications based on Node.js use more cnpm or npm in production environment, in China? Do not discuss yarn . I have seen some posts in major communities, it seems that cnpm will have more strange questions, and I also know about the pros and cons of npm and cnpm .

Mar.18,2021

set the domestic image with npm.


The node_modules directory structure generated by

npm and cnpm is different. cnpm generates an empty folder for each package, pointing to the actual package file directory, which is relatively messy.

in addition, using cnpm can only solve dependent downloads. Packages that need to download additional resources, such as node-sass , need to download an additional node file, which can only be decided by the author's script (mostly npm ). Very few packages automatically switch sources, such as vue-cli .

so it's best to use the npm download and set the repository directory to the cnpm source. The method can be npm config mentioned above, or you can set .npmrc

in the project directory.

npm sets up proxy

Menu