My tutor recently asked me to familiarize myself with the front-end scaffolding and public packages that my current team is using. Since it is too cumbersome and inconvenient to send the latest public package after the contents of each public package and then install the latest public package for the project, Baidu searched and used NPM Link to solve this problem. A good memory is not as good as a bad writing, record for the convenience of their subsequent use:
1. Pull the common package code from the repository to the local
2, run in the project root directorynpm link
3. Console inputpwd
Obtain the local package path
4, local use scaffolding to generate a new project, console inputNPM link {path to the local package name just obtained}
The public package in the node_modules module of the new project refers to the local public package project
The small arrow at the bottom right indicates that the common package orientation has changed. You can now run the local package, start the project, and take off to debug the common package
PS: I borrowed from the following article, but found inconsistencies, my humble opinion slightly changed
Segmentfault.com/a/119000002…
Step 1: Run NPM Link in the project root directory
npm link
Copy the code
Step 2: Run the PWD command in the project root directory to obtain the package path
pwd
Copy the code
Step 3: Run NPM Link XXX in the root directory of the package used outside the project
NPM link + Path of the packageCopy the code
Step 4: When changes are made in the project, the latest code is available outside the project.