NPM related knowledge records
- How to install
npm
? NPM is automatically installed when node is installed (recommended)nvmTo install) - Recommended
yarn
To manage NPM dependencies (faster, flat structures), and the latestpnpm
Worth studying - usenrmAdministration
registry
-
If the company has NPM private server and correspondingscope, you can set the scope to agree to specify the installation source for the packages from the same namespace to avoid the tedious task of switching the source back and forth, and there is no need to cut the source when publishing the NPM package under the scope
#Setting mode npm config set "@hp:registry" http://registry.npm.xxx.io yarn config set "@hp:registry" http://registry.npm.xxx.io
-
NPM contracting
1. npm logout 2. NPM login # successively enter the account, password and email address 3. NPM publish (you will be prompted to verify the email address on the NPM official website) Possible problems in NPM Publishing 1. Source error 2. Duplicate package name 3. Modify the package before each release The version number of JSON must be greater than the previous version number NPM link local debugging: for frequent contracting caused by debugging, you can use NPM link to proxy the NPM package to local debugging. Operation steps: Enter the source directory and execute NPM link Enter the use directory, that is, execute NPM link [package name] in the sample code. After folding, you can directly use import xxx from 'xxx' in the sample code for debugging