简体   繁体   中英

How to use library on an external project without uploading to NPM? Angular

I have 2 different angular apps and both of them will need to use a lot of the same services and interfaces, so I created added a third separate project and created a library there with some services and interfaces. After building the library I added the following to one of the 2 apps

package.json:

"daleeli-lib": "file:../SharedServices/dist/my-lib",

The problem with this is if I change the folder name of one of the files I will get an error as the library is no longer referenced:

Cannot find module 'my-lib' or its corresponding type declarations.

Is there a workaround to this without uploading the library to NPM?

You can use npm link like well explained in this link. https://medium.com/angular-in-depth/complete-beginner-guide-to-publish-an-angular-library-to-npm-d42343801660

or you can build your lib in locale and do a npm package. Import this pakage in your web app, and do an npm install 'yorfilepath'

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