As I was developing an Angular
application, I had the idea to create a library containing reusable components for future projects. To achieve this, I set up a separate Angular
workspace where I created a library project. I utilized the automatically generated application project within the workspace to preview individual components.
ng new my-components-library
cd my-components-library
ng generate library components-library
After successfully creating the library with functional components that passed unit tests and integrated well with the attached application project, I needed to incorporate them into my project's workspace. I attempted to include the library using the following method.
Within my project's workspace
npm install ../my-components-library/projects/components-library
The command executed without any issues, adding a reference to the library in the host project's package.json
. However, when I attempted to import modules from the external library into a project module using
import {myModule} from 'components-library'
, I encountered an error stating that Angular could not locate the module.