Skip to content

Scoped packages throw compilation errors #75

Closed
@jdjuan

Description

@jdjuan

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

  1. Create a new library: mkdir lib, cd lib, and yo angular2-library
  2. Generate a new clean angular app with angular-cli: ng new app-seed
  3. Modify your library package.json (the one in src, or the dist folder) to be scoped: "name": "@aaa/lib",
  4. Perform an NPM link of your library: npm link and then inside your app: npm link @aaa/lib
  5. Run ng build --prod --aot and see the console error below. Commands ng serve and ng 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions