I have this error in red when I serve from my CLI :
ERROR in Select2Module is not an NgModule webpack: bundle is now VALID.
ng build --aot error :
ERROR in Unexpected value 'Select2Module in /Users/Enigma/web/node_modules/ng2-select2/ng2-select2.d.ts' imported by the module 'AppModule in /Users/Enigma/web/src/app/app.module.ts'
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/Enigma/web/src'
@ ./src/main.ts 4:0-74
@ multi main
ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/Users/Enigma/web/src/$$_gendir' in '/Users/Enigma/web/node_modules/@angular/core/src/linker'
@ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
@ ./~/@angular/core/src/linker.js
@ ./~/@angular/core/src/core.js
@ ./~/@angular/core/index.js
@ ./src/main.ts
@ multi main
Any idea ?
OS : macOs Sierra
Related : angular/angular-cli#3426
package.json
{
"name": "web",
"version": "0.0.1",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"chart.js": "2.3.0",
"core-js": "^2.3.1",
"jquery": "^3.1.1",
"moment": "2.15.2",
"ng2-bootstrap": "^1.1.16-11",
"ng2-charts": "1.4.1",
"ng2-restangular": "^0.1.24",
"ng2-select2": "^1.0.0-beta.6",
"rxjs": "^5.0.2",
"select2": "^4.0.3",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.24",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.0.2",
"typescript": "~2.0.3"
}
}
angular-cli.json
{
"project": {
"version": "1.0.0-beta.24",
"name": "web"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"scss/style.scss"
],
"scripts": [
"../node_modules/chart.js/dist/Chart.bundle.min.js",
"../node_modules/chart.js/dist/Chart.min.js",
"../node_modules/jquery/dist/jquery.js",
"../node_modules/select2/dist/js/select2.full.js"
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LocationStrategy,
HashLocationStrategy } from '@angular/common';
import { HttpModule, Http } from '@angular/http';
import { FormsModule } from '@angular/forms';
// Components
import { AppComponent } from './app.component';
// Library
import { RestangularModule } from 'ng2-restangular';
import { Ng2BootstrapModule } from 'ng2-bootstrap/ng2-bootstrap';
import { Observable } from "rxjs/Observable";
import { Select2Module } from "ng2-select2";
// Security
import { AuthGuard } from "./_guards/auth.guard";
// Services
import { UserService } from "./_services/user.service";
import { AlertService } from "./_services/alert.service";
import { AuthenticationService } from "./_services/authentication.service";
// Routing
import { AppRoutingModule } from './app.routing';
export function configFunc (RestangularProvider, http) {
RestangularProvider.setBaseUrl('http://localhost:8888/web/');
let currentUser = JSON.parse(localStorage.getItem('currentUser'));
if (currentUser && currentUser.token) {
RestangularProvider.setDefaultHeaders({'Authorization': 'Bearer ' + currentUser.token});
}
}
@NgModule({
imports: [
BrowserModule,
AppRoutingModule,
Ng2BootstrapModule,
Select2Module,
RestangularModule.forRoot([Http], configFunc),
],
declarations: [
AppComponent
],
providers: [
{
provide: LocationStrategy,
useClass: HashLocationStrategy
},
UserService,
AuthenticationService,
AlertService,
AuthGuard
],
bootstrap: [ AppComponent ]
})
export class AppModule { }