Discussion on NPM related knowledge

Time:2022-1-7

NPM related knowledge records

  • How to installnpm? NPM is automatically installed when node is installed (recommended)nvmTo install)
  • RecommendedyarnTo manage NPM dependencies (faster, flat structures), and the latestpnpmWorth studying
  • usenrmAdministrationregistry
  • 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

Recommended Today

Springboot 2.6.3 integrated redis stepped on the pit

The integration steps are as follows: development tools: idea2019, JDK1.8, maven 3.5.4 Idea creates a new project, selects spring initializer, selects spring boot version 2.6.3 (the latest version at present), and adds web, and redis modules. After successful construction, the POM file is as follows: <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd”> <modelVersion>4.0.0</modelVersion> <parent> […]