When the npm package is developed, you can always see the effect

When we are developing npm package components, we want to see the effect during the development process, and this can be achieved through npm link

1) Associated dependency packages, here, we have two projects
npm-link-module, which is the npm module we want to develop,
npm-link-example, is the project we want to run the npm module

First, enter our npm-link-module project and execute npm link

Then, enter the npm-link-example project and execute npm link npm-link-module

Through the above two steps, the goal of seeing the effect from time to time can be achieved. Note that the order of the above steps cannot be exchanged

Introduce the package through link package and npm method. The import path of using the package may be different. Please pay attention

For example, through the npm installation package method, it was fine to directly import the package name directly, but if it is the npm link method, then the path of the imported component must be changed to import from node_modules


2) Unlink to
unlink the project and module link, under the project directory, the module name of npm unlink
Unlink the global link of the module, under the module directory, the name of the npm unlink module

The order of the above steps can be exchanged


There is a problem with the local link, that is, the package that has been installed in the project will be deleted after the link, and the package needs to be reinstalled after the link is removed.

Guess you like

Origin blog.csdn.net/tangxiujiang/article/details/110294647