当前位置:网站首页>A pot of stew, a collection of common commands of NPM and yarn cnpm

A pot of stew, a collection of common commands of NPM and yarn cnpm

2022-07-07 19:39:00 Milo_

1. Configure the mirror

npmmirror China mirror station


npm config get registry //  see npm Current mirror source 

npm config set registryhttps://registry.npmmirror.com/ //  Set up npm The image source is Taobao image 

yarn config get registry // see yarn Current mirror source 

yarn config set registry https://registry.npmmirror.com/ //  Set up yarn The image source is Taobao image 

2. Dependent installation

2.1 npm&cnpm

npm install xxx  It is also abbreviated as  npm i xxx  This is the most common way to download , It will install the package in the current directory node_modelus in 

npm install [email protected]1.x.x  It can be accurately installed to a certain version 

npm install --save xxx  It is also abbreviated as  npm install -s xxx  This method will write the downloaded module information to  package.json  Medium dependencies In the list 

npm install --save-dev xxx  It is also abbreviated as  npn install -D xxx  This method will write the downloaded module information to  package.json  Medium devDependencies In the list   Compared with the second method dependencies  Is a runtime dependency , and devDependencies It's a development dependency . in other words , use  --save-dev  The installed package will not be used after we release it , Only used in development 

npm install -g xxx  The module will be installed to the global , That is, under the global path configured above 

 Use  npm uninstall xxx  or  npm uninstall -g xxx  Uninstallable module , If all uninstalls, use  npm uninstall -all

2.2 yarn

yarn add package-name Installation package “ newest ” edition .
yarn add package-[email protected]1.2.3 Install a specific version of the package from the registry .
yarn add package-[email protected] Install specific  “ label ”( for example beta、next or latest).
原网站

版权声明
本文为[Milo_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071729281859.html