Ng-packagr: yarn link results in Unexpected value 'MyModule' imported by the module 'AppModule'. Please add a @NgModule annotation.

Created on 25 Sep 2017  路  4Comments  路  Source: ng-packagr/ng-packagr

Type of Issue

  • [X] Bug Report
  • [ ] Feature Request

Description

When linking the dist folder created by 'ng-packagr -p ng-package.json'. It throws a runtime error 'Unexpected value 'MyModule' imported by the module 'AppModule'. Please add a @NgModule annotation.' When publishing the same dist folder to npm and installing it, it does not give any errors.

Copying the files from the dist folder to the apps node modules works but this is not a solution that we want to pursue.

How To Reproduce

Run 'ng-packagr -p ng-package.json'. Link the dist folder by doing yarn link. Now go to the app that want to use the library and use yarn link my-library.

Expected Behaviour

Expected behaviour yarn link would give the same results as publishing to npm repo (for local development).

Version Information

ng-packagr: v1.2.0
node: v7.10.0
@angular: v4.2.4
rxjs: 5.4.2
zone.js: 0.8.14
documentation

Most helpful comment

For anyone else seeing this issue with Angular CLI, you have to launch ng serve with preserve symlinks like this:

ng serve --preserve-symlinks

I am using @angular/[email protected]

All 4 comments

For anyone else seeing this issue with Angular CLI, you have to launch ng serve with preserve symlinks like this:

ng serve --preserve-symlinks

I am using @angular/[email protected]

@matt328 Thanks for the answer. This indeed works 馃憤 Angular CLI should really add this to their documentation.

yeah the current cli story for using linked libs doesn't mention the flag.

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kroeder picture kroeder  路  3Comments

hamedbaatour picture hamedbaatour  路  4Comments

loicsalou picture loicsalou  路  4Comments

dareksob picture dareksob  路  4Comments

cnotarioArtica picture cnotarioArtica  路  4Comments