Javascript ng build工作,但ng build--prod抛出错误
我是一名通过建筑项目学习的学生。当我执行ng build时,它可以工作,但ng build--prod给出了一个错误 我已尝试删除节点_模块,然后重新安装 错误说明如下: ./src/app/app.module.ngfactory.js 41:3371-3377“导出‘ɵa’时出错 在“@angular/common”中找不到(作为“i12”导入) 这是我的package.json文件Javascript ng build工作,但ng build--prod抛出错误,javascript,angular,angular-cli,angular7,production,Javascript,Angular,Angular Cli,Angular7,Production,我是一名通过建筑项目学习的学生。当我执行ng build时,它可以工作,但ng build--prod给出了一个错误 我已尝试删除节点_模块,然后重新安装 错误说明如下: ./src/app/app.module.ngfactory.js 41:3371-3377“导出‘ɵa’时出错 在“@angular/common”中找不到(作为“i12”导入) 这是我的package.json文件 "name": "angular-project", "version": "0.0.0",
"name": "angular-project",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.0",
"@angular/cdk": "^8.1.3",
"@angular/common": "~8.2.0",
"@angular/compiler": "~8.2.0",
"@angular/core": "~8.2.0",
"@angular/forms": "~8.2.0",
"@angular/platform-browser": "~8.2.0",
"@angular/platform-browser-dynamic": "~8.2.0",
"@angular/router": "~8.2.0",
"@ng-bootstrap/ng-bootstrap": "^5.1.0",
"@types/socket.io-client": "^1.4.32",
"avatar-name-initials": "^2.0.5",
"bootstrap": "^4.3.1",
"express": "^4.17.1",
"ng2-file-upload": "^1.3.0",
"path": "^0.12.7",
"rxjs": "~6.4.0",
"rxjs-compat": "^6.5.4",
"socket.io-client": "^2.3.0",
"sweetalert2": "^8.16.1",
"time-ago-pipe": "^1.3.2",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.802.1",
"@angular/cli": "^8.3.0",
"@angular/compiler-cli": "^8.2.3",
"@angular/language-service": "~8.2.0",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"enhanced-resolve": "^3.3.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
}
}
生产配置
"configurations": {
"production": {
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
注意:如果我将aot和buildOptimizer设置为false,它会工作并且不会抛出错误。@LakshanMamalgaha是的,它成功地创建了dist文件夹,没有任何错误,因此您应该查看生产配置。@OlafDietsche我已在说明中添加了生产配置。是否尝试将Angular更新为最新版本版本?
ng update@angular/core@angular/cli
与常规(非prod)构建有什么区别?