Import library in library - error TS2307: Cannot find module
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
I have two libraries generated with Angular CLI. I also use Nrwl Nx
<@scope>/hello-world-a
<@scope>/hello-world-b
When I import hello-world-b
in hello-world-a
and try to build, I get the following error:
BUILD ERROR libs/hello-world-a/src/lib/hello-world-a.module.ts(3,35): error TS2307: Cannot find module ‘@<@scope>/hello-world-b’. libs\hello-world-a\src\lib\hello-world-a.module.ts(6,27): Error during template compile of ‘HelloWorldAModule’ Could not resolve @<@scope>/hello-world-b relative to D:/Projekte/Git/<@scope>-maps/libs/hello-world-a/src/lib/hello-world-a.module.ts… libs\hello-world-a\src\lib\hello-world-a.module.ts(6,27): Error during template compile of ‘HelloWorldAModule’ Could not resolve @<@scope>/hello-world-b relative to D:/Projekte/Git/<@scope>-maps/libs/hello-world-a/src/lib/hello-world-a.module.ts…
How To Reproduce
ng generate library hello-world-a
ng generate library hello-world-b
in hello-world-a.module.ts
import HelloWorldBModule
This should look like this:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HelloWorldBModule } from '@<scope>/hello-world-b';
@NgModule({
imports: [CommonModule, HelloWorldBModule]
})
export class HelloWorldAModule {}
Then run: ng-packagr -p libs/hello-world-a/package.json
Expected Behaviour
I expect to import one library in another library without error
Version Information
ng-packagr: 4.1.0
@angular/*: 6.1.0
typescript: 2.7.2
rxjs: 6..2.2.
node: 8.11.3
npm: 5.6.0
@nrwl/nx: 6.2.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
You need ng-packagr, but as a dependencies. As Angular CLI have a wrapper for it.
I think what you are describing is secondary entry points https://github.com/dherges/ng-packagr/blob/master/docs/secondary-entrypoints.md
Sorry for the short reply but I am currently commuting
On Fri, 24 Aug 2018 at 18:55, Daniel Groh notifications@github.com wrote:
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
This action has been performed automatically by a bot.