将@ angular / cli升级到版本1.7.4之后我遇到了问题。我已经尝试过较低版本,例如1.6.x,但这似乎与特定版本的相关性较小,而不是捆绑包的构建方式。我还创建了一个新的Angular项目,以验证供应商/主要捆绑包的提取方式与它们相同。
运行ng test
时,我在控制台(调试级别)中收到以下错误:
19 04 2018 10:14:11.861:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/vendor.bundle.js /
19 04 2018 10:14:11.861:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/vendor.bundle.js
19 04 2018 10:14:11.871:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/main.bundle.js /
19 04 2018 10:14:11.871:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/main.bundle.js
19 04 2018 10:14:13.500:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/vendor.bundle.js /
19 04 2018 10:14:13.500:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/vendor.bundle.js
19 04 2018 10:14:13.538:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/main.bundle.js /
19 04 2018 10:14:13.538:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/main.bundle.js
PhantomJS 2.1.1 (Windows 8.0.0) ERROR
{
"message": "SyntaxError: Parser error\nat http://localhost:9876/_karma_webpack_/vendor.bundle.js:264651:0",
"str": "SyntaxError: Parser error\nat http://localhost:9876/_karma_webpack_/vendor.bundle.js:264651:0"
}
PhantomJS 2.1.1 (Windows 8.0.0) ERROR
{
"message": "SyntaxError: Parser error\nat http://localhost:9876/_karma_webpack_/vendor.bundle.js:264651:0",
"str": "SyntaxError: Parser error\nat http://localhost:9876/_karma_webpack_/vendor.bundle.js:264651:0"
}
供应商文件列出的行号不存在,实际上并未指向真实错误。如果启动浏览器并将其指向Karma网址,则可以正常运行测试。更令人愤怒的是它还重新启动了PhantomJS中的测试并且它们执行得很好。无头Chrome也可以使用,但是这个版本服务我发送给Jenkins并且该团队除了PhantomJS之外没有任何支持。
如果有人有任何想法我会喜欢一些帮助。我整整一天都在反对这个问题。
相关套餐:
"@angular/animations": "4.3.6",
"@angular/common": "4.3.6",
"@angular/compiler": "4.3.6",
"@angular/core": "4.3.6",
"@angular/forms": "4.3.6",
"@angular/http": "4.3.6",
"@angular/platform-browser": "4.3.6",
"@angular/platform-browser-dynamic": "4.3.6",
"@angular/platform-server": "4.3.6",
"@angular/router": "4.3.6",
...
"karma": "^2.0.0",
"karma-chrome-launcher": "2.0.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "0.2.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"karma-phantomjs-launcher": "1.0.4",
"karma-sourcemap-loader": "0.3.7",
"phantomjs-prebuilt": "2.1.7",