我使用所有依赖项将我的SPA从Angular 4更新为Angular 5。到目前为止工作如此之好。开发和prod构建工作非常好。没有错误或警告。
当我使用--prod
标记构建SPA时,angular-cli
会对构建进行uglify。 angular-cli
没有错误。但是当我在浏览器中打开SPA时,出现错误并且没有任何反应。该页面根本不加载(仅加载微调器)。
Uncaught Error: Unexpected value 'Ie' imported by the module 't'. Please add a @NgModule annotation.
at c (compiler.js:466)
at compiler.js:15088
at Array.forEach (<anonymous>)
at t.getNgModuleMetadata (compiler.js:15071)
at t.getNgModuleSummary (compiler.js:14998)
at compiler.js:15086
at Array.forEach (<anonymous>)
at t.getNgModuleMetadata (compiler.js:15071)
at t._loadModules (compiler.js:33486)
at t._compileModuleAndComponents (compiler.js:33447)
这是我的package.json
所有依赖项和我的构建脚本:
{
"name": "broadcast-manager",
"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.53",
"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": {}
}
这是我的.angular-cli.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "broadcast"
},
"apps": [
{
"root": "src",
"outDir": "../public/frontend",
"assets": [
"assets",
".htaccess",
"favicon.ico",
{
"glob": "**/*",
"input": "../node_modules/font-awesome/fonts/",
"output": "./assets/fonts/"
}
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"prefix": "bm-",
"environmentSource": "environments/environment.ts",
"environments": {
"main": "environments/environment.ts"
}
}
],
"lint": [
{
"project": "src/tsconfig.app.json"
}
],
"defaults": {
"styleExt": "css",
"component": {
}
},
"warnings": {
"typescriptMismatch": false
}
}
如何调试发生的事情/出了什么问题?
答案 0 :(得分:0)
由于@Kevin RED,我通过以下简单解决方案修复了问题。
在:
"scripts": {
"prod": "ng build --prod --aot false"
}
后:
"scripts": {
"prod": "ng build --prod --aot false --build-optimizer=false"
}
我现在不确定build-optimizer
的功能是什么(npmjs-build-optimizer),但如果我将其设置为true
,则会收到错误消息。设置在false
上,它可以正常工作。