1

I am facing an issue related to npm link

This is the case of publishing modules locally and using them in other angular apps. I have 2 apps

1) app-core (published locally)
2) app-main

app-core contains following dependencies (installed via npm):

core
rxjs
zone
ng2-cache // Pay attention to this!
etc...


app-main contains following dependencies (installed via npm):

core
rxjs
http
etc...


I am linking app-core module to local npm using (sym link)

npm link

linked this module globally


Now I am using app-core inside my app-main using

npm link app-core

Things are good as of now, when i build my app-main it's showing me following errors:

ERROR in ../app-core/dist/core/services/remote.service.js
Module not found: Error: Can't resolve 'ng2-cache/ng2-cache' in 'C:\Dhaval\app-core\dist\core\services'
 @ ../app-core/dist/core/services/remote.service.js 14:18-48
 @ ../app-core/dist/upoint.core.js
 @ ./src/shared/shared.module.ts
 @ ./src/app-features/app-features.module.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
webpack: Failed to compile.

Explanation: ng2-cache was the dependency injected inside the app-core and ng2-cache itself is a kind of a custom module, so it became nesting now as i am using a Custom module (ng2-cache) inside another module app-core (my own) and this app-core i am using inside app-main.

This is the case that's bothering me, my app-main module isn't getting that ng2-cache module resolve within. What should i do?

Appreciate your efforts!

Dhaval Marthak
  • 17,246
  • 6
  • 46
  • 68

1 Answers1

0

It won't install dependencies of dependencies when using a linked project. Only when the project is published and then installed conventionally.

You should make a dependency on the same library in app-main

klonq
  • 3,535
  • 4
  • 36
  • 58