ng2-ui/popup

Angular cli - Rc1 - not able to build

vjangari opened this issue · 16 comments

When i add Ng2PopupModule to my project and I am getting below error

ERROR in Ng2PopupModule is not an NgModule

I am using angular 2.4.X with Angular cli rc1

Please show your package.json and console output here.

{
  "name": "test-ui",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "angular2-dynamic-component": "^1.3.15",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "ng2-popup": "^0.4.0",
    "rxjs": "^5.1.0",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-rc.1",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ng2-overlay": "^0.7.2",
    "protractor": "~5.1.0",
    "ts-metadata-helper": "0.0.4",
    "ts-node": "~2.0.0",
    "tslint": "~4.4.2",
    "typescript": "~2.0.0"
  }
}

Console Output:

** NG Live Development Server is running on http://localhost:3200 **
Hash: 3118b0fe9b208b5f388f
Time: 12298ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 157 kB {4} [initial]
 [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 145 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 197 kB {4} [initial] [rendere
d]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.19 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in Ng2PopupModule is not an NgModule
webpack: Failed to compile.

Did you add Ng2PopupModule into your main.ts? Could you add your main.ts?

It is working if i add entry to main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { Ng2PopupModule } from 'ng2-popup';
if (environment.production) {
enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);

Still getting error. Some how it worked yesterday and started getting same error again.

Please take look at your app.module

@NgModule({
  imports: [BrowserModule, FormsModule, Ng2PopupModule],
  declarations: [AppComponent],
  entryComponents: [],
  bootstrap: [ AppComponent ]
})
export class AppModule { }
// Compile and launch the module
platformBrowserDynamic().bootstrapModule(AppModule);

I have added in app.module.

If you edit file:
node_modules/ng2-popup/dist/ng2-popup.module.d.ts
then it works good

import { NgModule } from '@angular/core';
import { Ng2PopupComponent } from "./ng2-popup.component";
import { Ng2MessagePopupComponent } from "./ng2-message-popup.component";

@NgModule({
    declarations: [Ng2PopupComponent, Ng2MessagePopupComponent],
    exports: [Ng2PopupComponent, Ng2MessagePopupComponent]
})
export declare class Ng2PopupModule {}

@vjangari please make PR for this.

I see. It's better to have ng2-overlay as dependencies, not devDependencies

 "dependencies": {
    "ng2-overlay": "^0.7.0"
  }

@allenhwkim what do you mean by PR ?

it did not worked even if i add dependency

PR: a pull request.