The vUE project uses a local component library. When the code in the component library is updated, it is expected that the project will also be updated accordingly. In this case, NPM link can be used to create a soft link to achieve this

Soft link: create a global link for the developed module (NPM package), link the module’s dependencies in the main project,

Conduct tests;

1. Create, use, and delete soft connections

(1) Create a global link in the file of the corresponding NPM package;

CD test // Switch to NPM package file NPM link // create a global connection, generally can be viewed in the NPM installation path: C: Program Files\nodejs\node_modules\testCopy the code

(2) Use NPM dependencies in the main project

NPM link test (test represents the project name of the package.json field value in NPM);Copy the code

(3) Remove the soft connection

3.1 Remove global connections in the directory where the NPM package resides

NPM unlink // Switch to the directory where the NPM package residesCopy the code

3.2 Unlink specific links under projects that use NPM packages

NPM Unlink Test (Switch to project)Copy the code

Reference article: juejin.cn/post/684490…