Skip to content

"Please add a @NgModule annotation." error with AOT, full path vs short package.json main #6239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
FriOne opened this issue May 9, 2017 · 4 comments

Comments

@FriOne
Copy link

FriOne commented May 9, 2017

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Windows 7
@angular/cli: 1.0.2
node: 6.9.0
os: win32 x64
@angular/common: 4.1.1
@angular/compiler: 4.1.1
@angular/core: 4.1.1
@angular/forms: 4.1.1
@angular/http: 4.1.1
@angular/platform-browser: 4.1.1
@angular/platform-browser-dynamic: 4.1.1
@angular/router: 4.1.1
@angular/cli: 1.0.2
@angular/compiler-cli: 4.1.1

Repro steps.

ng serve works ok, but aot compilation fails in case:
import module like import { Ng2FlatpickrModule } from 'ng2-flatpickr/lib/ng2-flatpickr.module.js';
-> No errors
import module like import { Ng2FlatpickrModule } from 'ng2-flatpickr;
-> "Please add a @NgModule annotation." error

The log given by the failure.

ERROR in Unexpected value 'Ng2FlatpickrModule in .../node_modules/ng2-flatpickr/lib/ng2-flatpickr.module.js' imported by the module 'AppModule in .../src/app/app.module.t
s'. Please add a @NgModule annotation.

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\Projects\work\unleesh-frontend\src'
@ ./src/main.ts 6:0-74
@ multi ./src/main.ts

Desired functionality.

There should be no errors

Mention any other details that might be useful.

Here is my fork https://github.com/FriOne/ng2-flatpickr

@FriOne FriOne changed the title "Please add a @NgModule annotation." error with AOT, full path vs short packa.json main "Please add a @NgModule annotation." error with AOT, full path vs short package.json main May 9, 2017
@filipesilva
Copy link
Contributor

This really sounds like a problem with how that library is published. We don't yet have a full guide for how to do it, but there's WIP version that you can direct the author to in angular/angular#16486

@tmakuch
Copy link

tmakuch commented May 14, 2017

@filipesilva, did you worked with webpack to create the lib. I see that you're using rollup to bundle your code in your lib quickstart.

I'm facing missing NgModule annotation issue in my custom library and I'm trying to debug what is the root case. As far as I understood the issue is that awsome-typescript-loader/ts-loader for webpack does not parse the code compiler-friendly - the module is exported with all the required properties, but it's not exported as a NgModule object. Thus the compiler fails to load the exported module as it does the typecheking expecting instance of NgModule.

Currently I want to check @ngTools/webpack or ngc (either vanilla or throught ngc-webpack). You are using ngc, what would confirm my theory.

@pro-soochee
Copy link

Facing same issue, ERROR in Error: Unexpected value 'JSONEditorModule in /node_modules/ng2-jsoneditor/dist/ng2-jsoneditor.d.ts' imported by the module 'AppModule in /src/app/app.module.ts'. Please add a @NgModule annotation.

This is a third-party library and there is no annotation for module or component. How would I update that library? or is there any other way to add the annotation for that module?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants