Reputation: 900
I have an Angular 6 app that has the following nested module structure:
├── node_modules/
├── package.json <- no mention of ngx-cookie-service
└── src/
└── app/
├── app.module.ts
└── sub-module/
├── node_modules/
├── package.json <- has dependency for ngx-cookie-service
└── sub.module.ts
The purpose of this structure is that the submodule can be published as an npm package and the appmodule provides a website UI for using the submodule's functions.
I'm getting the following error when trying to run ng build --aot
for the root project (appmodule):
ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve 'ngx-cookie-service/cookie-
service/cookie.service' in 'myapp\src\app'
Notes:
ngx-cookie-service
is declared as a dependency in the package.json under sub-module
.ngx-cookie-service
as a devDependency in the root package.json, the build succeeds--aot
works perfectlyMy first question is:
Is this a problem in my configuration or is it something about which I should contact the author of ngx-cookie-service
?
And another folllow-up question:
How to resolve this error without adding a dependency for ngx-cookie-service
in the root package.json? (Because that app doesn't itself need the cookie service, only the submodule needs it)
Upvotes: 0
Views: 1041
Reputation: 1605
I suggest you to create a angular workspace where you can able to create multiple libraries and Applications. https://angular.io/guide/workspace-config
read this post for better understanding
https://blog.angularindepth.com/angular-workspace-no-application-for-you-4b451afcc2ba
Upvotes: 1