ng build --prod --aot error
Bug Report or Feature Request (mark with an x)
- [ ] bug report -> please search issues before submitting
- [ ] feature request
Versions.
Angular CLI: 1.5.0
Node: 8.1.3
OS: win32 x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/animation: 4.0.0-beta.8
@angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.0
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.2
typescript: 2.4.2
webpack-bundle-analyzer: 2.9.1
webpack: 3.8.1
Repro steps.
Update angular to 5.0.1 Update angular material to 5.0.0-rc0
ng build --prod --aot=true
package.json
"dependencies": {
"@angular/animation": "latest",
"@angular/animations": "5.0.1",
"@angular/cdk": "5.0.0-rc0",
"@angular/common": "5.0.1",
"@angular/compiler": "5.0.1",
"@angular/core": "5.0.1",
"@angular/forms": "5.0.1",
"@angular/http": "5.0.1",
"@angular/material": "5.0.0-rc0",
"@angular/platform-browser": "5.0.1",
"@angular/platform-browser-dynamic": "5.0.1",
"@angular/router": "5.0.1",
"@types/crypto-js": "^3.1.35",
"@types/d3": "^4.10.0",
"@types/express": "latest",
"@types/nconf": "latest",
"@types/socket.io-client": "latest",
"amqplib": "latest",
"angular2-cookie": "latest",
"angular2-jwt": "latest",
"async": "latest",
"aws-sdk": "^2.113.0",
"body-parser": "latest",
"bootstrap": "latest",
"compression": "^1.7.0",
"cookie-parser": "latest",
"core-js": "latest",
"crypto-js": "^3.1.9-1",
"d3": "^4.10.2",
"express": "latest",
"express-session": "latest",
"hammerjs": "latest",
"loadtest": "latest",
"method-override": "latest",
"moment": "^2.19.2",
"nconf": "latest",
"ng2-translate": "latest",
"no-kafka": "latest",
"request": "latest",
"rxjs": "latest",
"socket.io": "latest",
"sqs-consumer": "^3.7.0",
"systemjs": "latest",
"typings": "latest",
"zone.js": "latest",
"typescript": "2.4.2"
}
tsconfig.json
{
"compilerOptions": {
"rootDir": ".",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"lib": [
"es2017",
"dom"
],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"node_modules/@types"
],
"watch": false
},
"compileOnSave": true,
"exclude": [
"node_modules",
"polyfills.ts"
]
}
systemjs.config.js
(function (global) {
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
// path on own project
app: 'app',
// angular packages
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/material': 'npm:@angular/material/bundles/material.umd.js',
'@angular/cdk': 'npm:@angular/cdk/bundles/cdk.umd.js',
// CDK Secondary entry points
'@angular/cdk': 'npm:@angular/cdk/bundles/cdk.umd.js',
'@angular/cdk/a11y': 'npm:@angular/cdk/bundles/cdk-a11y.umd.js',
'@angular/cdk/bidi': 'npm:@angular/cdk/bundles/cdk-bidi.umd.js',
'@angular/cdk/coercion': 'npm:@angular/cdk/bundles/cdk-coercion.umd.js',
'@angular/cdk/collections': 'npm:@angular/cdk/bundles/cdk-collections.umd.js',
'@angular/cdk/keycodes': 'npm:@angular/cdk/bundles/cdk-keycodes.umd.js',
'@angular/cdk/observers': 'npm:@angular/cdk/bundles/cdk-observers.umd.js',
'@angular/cdk/overlay': 'npm:@angular/cdk/bundles/cdk-overlay.umd.js',
'@angular/cdk/platform': 'npm:@angular/cdk/bundles/cdk-platform.umd.js',
'@angular/cdk/portal': 'npm:@angular/cdk/bundles/cdk-portal.umd.js',
'@angular/cdk/rxjs': 'npm:@angular/cdk/bundles/cdk-rxjs.umd.js',
'@angular/cdk/scrolling': 'npm:@angular/cdk/bundles/cdk-scrolling.umd.js',
'@angular/cdk/stepper': 'npm:@angular/cdk/bundles/cdk-stepper.umd.js',
'@angular/cdk/table': 'npm:@angular/cdk/bundles/cdk-table.umd.js',
'@angular/cdk/accordion': 'npm:@angular/cdk/bundles/cdk-accordion.umd.js',
'@angular/cdk/layout': 'npm:@angular/cdk/bundles/cdk-layout.umd.js',
'@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
'@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
'@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
//temp fix according to https://github.com/ReactiveX/rxjs/issues/2971
'rxjs/operators': 'npm:rxjs/operators/index.js',
'rxjs/operators/filter': 'npm:rxjs/operators/filter.js',
'rxjs/operators/switchMap': 'npm:rxjs/operators/switchMap.js',
'rxjs/operators/first': 'npm:rxjs/operators/first.js',
'rxjs/operators/tap': 'npm:rxjs/operators/tap.js',
'rxjs/operators/delay': 'npm:rxjs/operators/delay.js',
'rxjs/operators/startWith': 'npm:rxjs/operators/startWith.js',
'rxjs/operators/catchError': 'npm:rxjs/operators/catchError.js',
'rxjs/operators/map': 'npm:rxjs/operators/map.js',
'rxjs/operators/share': 'npm:rxjs/operators/share.js',
'rxjs/operators/finalize': 'npm:rxjs/operators/finalize.js',
'rxjs/operators/takeUntil': 'npm:rxjs/operators/takeUntil.js',
'rxjs/operators/combineLatest': 'npm:rxjs/operators/combineLatest.js',
'rxjs/operators/debounceTime': 'npm:rxjs/operators/debounceTime.js',
'rxjs/operators/auditTime': 'npm:rxjs/operators/auditTime.js',
'tslib': 'npm:tslib/tslib.js',
// another packages
'rxjs': 'npm:rxjs',
'socket.io-client': 'npm:socket.io-client/dist/socket.io.js',
'ng2-translate': 'npm:ng2-translate/bundles/ng2-translate.umd.js',
'angular2-cookie': 'npm:angular2-cookie',
'angular2-jwt': 'npm:angular2-jwt/angular2-jwt.js',
'moment/moment': 'npm:moment/min/moment-with-locales.min.js',
'crypto-js': 'npm:crypto-js/crypto-js.js',
'd3-format': 'npm:d3-format/build/d3-format.js',
'd3-array': 'npm:d3-array/build/d3-array.js',
'd3-brush': 'npm:d3-brush/build/d3-brush.js',
'd3-dispatch': 'npm:d3-dispatch/build/d3-dispatch.js',
'd3-drag': 'npm:d3-drag/build/d3-drag.js',
'd3-selection': 'npm:d3-selection/build/d3-selection.js',
'd3-interpolate': 'npm:d3-interpolate/build/d3-interpolate.js',
'd3-color': 'npm:d3-color/build/d3-color.js',
'd3-transition': 'npm:d3-transition/build/d3-transition.js',
'd3-timer': 'npm:d3-timer/build/d3-timer.js',
'd3-ease': 'npm:d3-ease/build/d3-ease.js',
'd3-force': 'npm:d3-force/build/d3-force.js',
'd3-quadtree': 'npm:d3-quadtree/build/d3-quadtree.js',
'd3-collection': 'npm:d3-collection/build/d3-collection.js',
'd3-hierarchy': 'npm:d3-hierarchy/build/d3-hierarchy.js',
'd3-scale': 'npm:d3-scale/build/d3-scale.js',
'd3-time': 'npm:d3-time/build/d3-time.js',
'd3-time-format': 'npm:d3-time-format/build/d3-time-format.js',
'd3-shape': 'npm:d3-shape/build/d3-shape.js',
'd3-path': 'npm:d3-path/build/d3-path.js'
},
defaultJSExtensions: 'js',
transpiler: 'typescript',
typescriptOptions: { emitDecoratorMetadata: true },
packages: {
app: {
main: './src/core/main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'ng2-translate': {
defaultExtension: 'js'
},
'angular2-cookie': {
main: './core.js',
defaultExtension: 'js'
},
'socket.io-client': {
defaultExtension: 'js'
},
'angular2-jwt': {
defaultExtension: 'js'
}
}
});
})(this);
angular-cli.json
{
"project": {
"version": "1.0.0",
"name": "Application UI"
},
"apps": [
{
"root": ".",
"outDir": "dist",
"deployUrl": "/",
"assets": [
"app/resources/",
"app/src/model/eco/*.json",
"favicon.ico"
],
"index": "lib/view/index.prod.html",
"main": "app/src/core/main.prod.ts",
"polyfills": "./polyfills.ts",
"tsconfig": "tsconfig.json",
"test": "./test/test.ts",
"testTsconfig": "./test/tsconfig.spec.json",
"prefix": "app",
"styles": [
"app/resources/styles/date-time-picker/picker.css",
"app/resources/styles/main.css",
"app/resources/styles/media.css"
],
"scripts": []
}
],
"test": {
"karma": {
"config": "./test/karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
}
}
}
The log given by the failure.
λ ng build --prod --aot=true
Date: 2017-11-14T05:39:22.920Z
Hash: afd8f172da62e82107b5
Time: 123746ms
chunk {0} main.015517f868421932eca3.bundle.js (main) 2.5 MB [initial] [rendered]
chunk {1} styles.4fd7e6c65b8394fe0574.bundle.css (styles) 25.9 kB [initial] [rendered]
chunk {2} polyfills.b3df333df05654cecd25.bundle.js (polyfills) 530 bytes [initial] [rendered]
chunk {3} inline.d0ad74d2d45d9d6b7449.bundle.js (inline) 1.45 kB [entry] [rendered]
ERROR in ./polyfills.ts
Module build failed: Error: C:\Git\ECO_web\polyfills.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (C:\Git\ECO_web\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (C:\Git\ECO_web\node_modules\@ngtools\webpack\src\loader.js:467:39)
at <anonymous>
@ multi ./polyfills.ts
@AlexeyMikheev Hi, Mr.Alexey, I think this error occurs because you did not config tsconfig.json file correctly:
"exclude": [
"node_modules",
**"polyfills.ts"**
]
when you configed polyfill.ts in this 'exclude' property, it means you tell compiler do not compile pollyfill.ts file.
Hope it helps!
Thanks!
I change
.angular-cli.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "Application UI"
},
"apps": [
{
"root": ".",
"outDir": "dist",
"deployUrl": "/",
"assets": [
"app/resources/",
"app/src/model/eco/*.json",
"favicon.ico"
],
"index": "lib/view/index.prod.html",
"main": "app/src/core/main.prod.ts",
"polyfills": "polyfills.ts",
"tsconfig": "tsconfig.app.json",
"test": "./test/test.ts",
"testTsconfig": "./test/tsconfig.spec.json",
"prefix": "app",
"styles": [
"app/resources/styles/date-time-picker/picker.css",
"app/resources/styles/main.css",
"app/resources/styles/media.css"
],
"scripts": []
}
],
"test": {
"karma": {
"config": "./test/karma.conf.js"
}
},
"defaults": {
"styleExt": "css"
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"watch": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"forceConsistentCasingInFileNames": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
tsconfig.app.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "es2015"
},
"include": [
"app/src/**/*.ts",
"polyfills.ts"
],
"exclude": [
"./test/test.ts",
"./app/src/test/*",
"./app/src/**/*.spec.ts"
]
}
Run commnad
ng build -prod -aot -vc = true
In console all success
Date: 2017-11-15T11:34:20.696Z
Hash: d4b425334145b9e4a378
Time: 147206ms
chunk {0} polyfills.38ca2d12533b0be83c8e.bundle.js (polyfills) 104 kB [initial] [rendered]
chunk {1} main.8b667c05a705c9d3bf9a.bundle.js (main) 528 kB [initial] [rendered]
chunk {2} styles.9695d0019769da6edb45.bundle.css (styles) 26.5 kB [initial] [rendered]
chunk {3} vendor.49de13943896ce246571.bundle.js (vendor) 1.51 MB [initial] [rendered]
chunk {4} inline.c14addb2deaf80b912ca.bundle.js (inline) 1.45 kB [entry] [rendered]
But in browser console error
Uncaught Error: No NgModule metadata found for 'e'.
at t.resolve (vendor.49de13943896ce246571.bundle.js:1)
at t.getNgModuleMetadata (vendor.49de13943896ce246571.bundle.js:1)
at t._loadModules (vendor.49de13943896ce246571.bundle.js:1)
at t._compileModuleAndComponents (vendor.49de13943896ce246571.bundle.js:1)
at t.compileModuleAsync (vendor.49de13943896ce246571.bundle.js:1)
at t.compileModuleAsync (vendor.49de13943896ce246571.bundle.js:1)
at t.bootstrapModule (vendor.49de13943896ce246571.bundle.js:1)
at Object.xplT (main.8b667c05a705c9d3bf9a.bundle.js:1)
at n (inline.c14addb2deaf80b912ca.bundle.js:1)
at Object.0 (main.8b667c05a705c9d3bf9a.bundle.js:1)
If run
ng build --prod --no-aot
error in browser console
Uncaught Error: Unexpected value 'e' imported by the module 'e'. Please add a @NgModule annotation.
at c (main.675c14b4ad553b520e4f.bundle.js:1)
at main.675c14b4ad553b520e4f.bundle.js:1
at Array.forEach (<anonymous>)
at e.getNgModuleMetadata (main.675c14b4ad553b520e4f.bundle.js:1)
at e._loadModules (main.675c14b4ad553b520e4f.bundle.js:1)
at e._compileModuleAndComponents (main.675c14b4ad553b520e4f.bundle.js:1)
at e.compileModuleAsync (main.675c14b4ad553b520e4f.bundle.js:1)
at e.compileModuleAsync (main.675c14b4ad553b520e4f.bundle.js:1)
at e.bootstrapModule (main.675c14b4ad553b520e4f.bundle.js:1)
at Object.xplT (main.675c14b4ad553b520e4f.bundle.js:1)
I change main.ts
From
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
to
platformBrowserDynamic().bootstrapModule(AppModule);
Run command
ng build --prod -aot=true -vc=true
and error resolve.
Thanks!
Hi @ all.
I have the same problem when running my angular 5.0.1 in prod. In dev I got no error messages.
First of all, my dependencies. I am updating right now from Angular 4 to 5 with all dependencies to the newest version.
{
"name": "myapplication",
"version": "0.1.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"dev": "ng serve --dev --environment main --port 1337 --host 0.0.0.0 --proxy-config proxy.conf.json",
"prod": "ng build --prod --environment main --aot false"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.1",
"@angular/cli": "^1.5.0",
"@angular/common": "^5.0.1",
"@angular/compiler": "^5.0.1",
"@angular/compiler-cli": "^5.0.1",
"@angular/core": "^5.0.1",
"@angular/forms": "^5.0.1",
"@angular/http": "^5.0.1",
"@angular/platform-browser": "^5.0.1",
"@angular/platform-browser-dynamic": "^5.0.1",
"@angular/router": "^5.0.1",
"@swimlane/ngx-charts": "^6.1.0",
"@swimlane/ngx-datatable": "^11.0.4",
"@types/jwt-decode": "^2.2.1",
"@types/node": "^8.0.52",
"bootstrap": "4.0.0-alpha.6",
"codelyzer": "^4.0.1",
"core-js": "^2.5.1",
"d3": "^4.11.0",
"jwt-decode": "2.2.0",
"moment": "^2.19.2",
"ng2-dnd": "^4.2.0",
"ngx-bootstrap": "^2.0.0-beta.8",
"ngx-chips": "^1.5.9",
"node-sass": "^4.6.1",
"protractor": "^5.2.0",
"rxjs": "^5.5.2",
"ts-node": "^3.3.0",
"tslint": "^5.8.0",
"typescript": "^2.6.1",
"zone.js": "^0.8.18"
},
"devDependencies": {}
}
Following error appears in production build:
Uncaught Error: Unexpected value 'Ie' imported by the module 't'. Please add a @NgModule annotation.
Update
When I remove the --prod flag, it works. But it works now with uncompressed and unuglyfied files. How to debug this?
Kind regards, Matt.
Hi matibaski !
Pls, show yours tsconfig.json, tsconfig.app.json, main.ts.
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
},
"exclude": [
"node_modules"
]
}
tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
},
"exclude": [
"node_modules",
"test.ts",
"**/*.spec.ts"
]
}
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'; // external definitions
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
environment.ts
export const environment = {
production: false,
base_url: 'http://backend.app/api',
max_upload_size: 67108864
};
I can't make replay your error, try change config as here (replace project folders paths)
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"watch": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"forceConsistentCasingInFileNames": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
tsconfig.app.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "es2015"
},
"include": [
"app/src/**/*.ts",
"polyfills.ts"
],
"exclude": [
"node_modules",
"./test/test.ts",
"./app/src/test/*",
"./app/src/**/*.spec.ts"
]
}
Thank you for your help Alexey, but your solution didn't work out.
I don't even see a difference between your tsconfig.app.json and mine. I don't think it's a TypeScript problem because angular-cli would have returned an error while compiling with npm run prod.
I fixed the problem with following, easy solution:
Before:
"scripts": {
"prod": "ng build --prod --aot false"
}
After:
"scripts": {
"prod": "ng build --prod --aot false --build-optimizer=false"
}
I'm not sure right now what the functionality of build-optimizer is (npmjs-build-optimizer), but if I set it to true, I receive an error. Set on false and it works.
ERROR in Error: Error encountered resolving symbol values statically. Reference to a local (non-exported) symbol 'myDpStyles'. Consider exporting the symbol (position 9:7 in the original .ts file), resolving symbol MyDatePicker in
I fixed the problem with following, easy solution:
Before:
"scripts": { "prod": "ng build --prod --aot false" }After:
"scripts": { "prod": "ng build --prod --aot false --build-optimizer=false" }I'm not sure right now what the functionality of
build-optimizeris (npmjs-build-optimizer), but if I set it totrue, I receive an error. Set onfalseand it works.
i Did not get dist folder after build
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.