Closed
Description
When I try to compile an application for production that uses a library which has an NPM scope, it throws errors and fails.
Reproduction Steps
- Create a new library:
mkdir lib
,cd lib
, andyo angular2-library
- Generate a new clean angular app with angular-cli:
ng new app-seed
- Modify your library
package.json
(the one insrc
, or thedist
folder) to be scoped:"name": "@aaa/lib",
- Perform an
NPM link
of your library:npm link
and then inside your app:npm link @aaa/lib
- Run
ng build --prod --aot
and see the console error below. Commandsng serve
andng build
work well.
You can also clone this repo and jump to step 3.
Error
ERROR in C:/Users/jherrera/repos/PROD-ISSUE3/app-seed/src/$$_gendir/app/app.component.ngfactory.ts (1,1): Cannot find module 'lib'.
ERROR in C:/Users/jherrera/repos/PROD-ISSUE3/app-seed/src/$$_gendir/node_modules/@aaa/lib/lib.ngfactory.ts (1,1): Cannot find module 'lib'.
ERROR in C:/Users/jherrera/repos/PROD-ISSUE3/app-seed/src/$$_gendir/app/app.module.ngfactory.ts (1,1): Cannot find module 'lib'.
ERROR in C:/Users/jherrera/repos/PROD-ISSUE3/app-seed/src/$$_gendir/app/app.module.ngfactory.ts (1,1): Cannot find module 'lib'.
ERROR in C:/Users/jherrera/repos/PROD-ISSUE3/app-seed/src/$$_gendir/app/app.component.ngfactory.ts (1,1): Cannot find module 'lib'.
ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts
Module not found: Error: Can't resolve 'lib' in 'C:\Users\jherrera\repos\PROD-ISSUE3\app-seed\src\$$_gendir\app'
@ ./src/$$_gendir/app/app.module.ngfactory.ts 23:0-31
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./src/$$_gendir/app/app.component.ngfactory.ts
Module not found: Error: Can't resolve 'lib' in 'C:\Users\jherrera\repos\PROD-ISSUE3\app-seed\src\$$_gendir\app'
@ ./src/$$_gendir/app/app.component.ngfactory.ts 10:0-31
@ ./src/$$_gendir/app/app.module.ngfactory.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in C:/Users/jherrera/repos/PROD-ISSUE3/app-seed/src/$$_gendir/node_modules/@aaa/lib/lib.ngfactory.ts (1,1): Cannot find module 'lib'.
ERROR in ./src/$$_gendir/~/@aaa/lib/lib.ngfactory.ts
Module not found: Error: Can't resolve 'lib' in 'C:\Users\jherrera\repos\PROD-ISSUE3\app-seed\src\$$_gendir\node_modules\@aaa\lib'
@ ./src/$$_gendir/~/@aaa/lib/lib.ngfactory.ts 18:0-31
@ ./src/$$_gendir/app/app.component.ngfactory.ts
@ ./src/$$_gendir/app/app.module.ngfactory.ts
@ ./src/main.ts
@ multi ./src/main.ts
Environment
- NPM: 4.5.0
- Node: 7.9.0
- Angular CLI: 1.0.0
- Generator-angular2-libary: 9.0.0
- OS: Windows 10
Metadata
Metadata
Assignees
Labels
No labels