Local angular library in an NPM workspaces project

685 Views Asked by At

I have a local angular library created using ng generate library utils.

I then add its dependency to my angular project package.json, making sure to link to the inner lib folder under utils/dist/utils, and everything is working as expected:

"utils": "file:../utils/dist/utils"

When I look at the content of node_modules/utils in my angular module I see the content of utils/dist/utils.

I'm now refactoring the project to use NPM Workspaces so I can remove the dependency and NPM will install it automatically since it is a workspace.

The issue is that NPM is taking the entire root folder of the library and not the inner dist/utils folder and everything breaks.

When I look at the content of node_modules/utils in the root folder I now see the content of utils.

I get an error in all my imports stating:

TS2307: Cannot find module 'utils' or its corresponding type declarations.

Is there a proper solution to this issue?

0

There are 0 best solutions below