当我通过Ng Serve或Ng服务运行项目时,我的项目完美运行 - 但是在生产模式(--prod)中它会发生刷新
答案 0 :(得分:0)
您的问题很可能是由于某些npm软件包之间不兼容。如果您使用Angular CLI,则应执行以下操作(这是我根据您提供的信息提供帮助的最简单方法):
npm install -g @angular/cli@1.6.2
中运行此命令来升级Angular CLI。 接下来,在您的package.json
文件中,确保您的npm软件包具有相同的版本和版本。语义版本控制,即*
,^
或~
如下所示(我通过使用Angular CLI 1.6.2生成项目得到此信息):
请记住保留以下除您仍然使用的库以外的任何库!
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.6.2",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
package.json
所在的项目文件夹中,删除node_modules
文件夹并运行npm install
。