Skip to content

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

Closed

Description

@FriOne

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

Activity

  1. 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`[/+] on May 9, 2017
  2. filipesilva commented on May 10, 2017

    @filipesilva
    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

  3. tmakuch commented on May 14, 2017

    @tmakuch

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

  4. pro-soochee commented on Nov 20, 2017

    @pro-soochee

    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?

  5. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    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.

  6. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions