简体   繁体   中英

Is it possible to use NPM Link for an angular library without first building the library?

I have an angular library that can be built into a node module.

In order to use my local version without publishing it, and test that it is working on several apps, I am trying to use the npm link command.

I have done this by navigating to the dist folder of my library where package.json is found and running npm link. I then navigate to the app I want to use it and run npm link THE_LIBRARY_NAME. This works fine but if I update the library I will need to rebuild it, and when I rebuild it the link breaks so I have to repeat the steps.

If I try to link to the library itself, and not the node module it outputs, I get a 'Cant find module' error.

What am I doing wrong please?

Trying to link to the library itself does seem to actually work, I can find it in node_modules, but to clarify the import does not find that module.

You have to build the library and link that, but if you build the library with watch mode, then link it, any changes after this will not require the link to be setup again. The app using the library will recompile automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM