当前位置:网站首页>[cnpm] tutorial

[cnpm] tutorial

2022-06-24 07:19:00 A meteor unwilling to fall

npm Because the source server is located abroad , download node Packet speed is slow ,cnpm Use domestic image , Download speed is better than npm

One 、 Installation test

  • The publication number can be checked after installation , Indicates successful installation
#  Installation instructions 
npm i cnpm -g

#  Detection command 
cnpm -v
  • cnpm Use : hold npm Of is replaced by cnpm Just go
  • such as :npm i amount to cnpm i

Two 、 Difference between them

1. Domestic use npm The problem is

  • install npm after , Every time we install a package , Our computers must be compatible with npm The server has a conversation , Go to npm Warehouse acquisition package .
  • npm The default warehouse address is :http://registry.npmjs.org
#  View the current npm Warehouse address command 
*  npm config get registry
http://registry.npmjs.org
  • because npm The remote server is abroad , So sometimes it is inevitable that the access is too slow , Even inaccessible .
  • Taobao has built a domestic npm The server , It is now every 10 Minutes will go abroad npm Everything in the warehouse “ Carry ” Back to the domestic server , In this way, we can directly access the domestic server of Taobao ,
  • Its address is :https://registry.npm.taobao.org

Solution 1 :

  • Direct installation cnpm Install the software provided by Taobao cnpm, And change the server address to Taobao's domestic address ,
  • command :npm install -g cnpm --registry=https://registry.npm.taobao.org,
  • In the future, it will be installed directly cnpm replace npm,
  • For example, the original npm The order is :npm install uniq --save,cnpm The order is :cnpm install uniq --save

Solution 2 :

  • Replace npm The warehouse address is Taobao image address ( recommend )
  • command :npm config set registry https://registry.npm.taobao.org,
  • See if the change was successful :npm config get registry,
  • When installing later , Still use npm command , But it was actually downloaded from Taobao's domestic server
原网站

版权声明
本文为[A meteor unwilling to fall]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240126022877.html