我能够使用“ng test”成功运行测试应用程序,但每当我在运行时对测试文件进行任何更改时,我最终都会遇到错误。我已尝试过以下链接中提到的几种解决方案,但没有运气。请帮我解决这个问题。
的package.json
{
"name": "testing-demo",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/cli": "^1.2.0",
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"core-js": "^2.4.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/cli": "^1.6.7",
"@angular/compiler-cli": "^2.3.1",
"@ngtools/webpack": "^1.6.2",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"puppeteer": "^1.0.0",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "2.5.3"
}
}
https://github.com/angular/angular-cli/issues/5053
Angular CLI - Typescript throws: Cannot read property 'length' of undefined
为引用粘贴整个错误 -
ERROR in TypeError: Cannot read property 'length' of undefined
at createSourceFile (C:\testing-demo\node_modules\typescript\lib\typescri
pt.js:8982:109)
at parseSourceFileWorker (C:\testing-demo\node_modules\typescript\lib\typ
escript.js:8941:26)
at Object.parseSourceFile (C:\testing-demo\node_modules\typescript\lib\ty
pescript.js:8900:26)
at Object.createSourceFile (C:\testing-demo\node_modules\typescript\lib\t
ypescript.js:8728:29)
at new TypeScriptFileRefactor (C:\testing-demo\node_modules\@ngtools\webp
ack\src\refactor.js:79:35)
at Object.findLazyRoutes (C:\testing-demo\node_modules\@ngtools\webpack\s
rc\lazy_routes.js:18:22)
at AotPlugin._findLazyRoutesInAst (C:\testing-demo\node_modules\@ngtools\
webpack\src\plugin.js:216:50)
at _donePromise.Promise.resolve.then.then.then.then.then (C:\testing-demo
\node_modules\@ngtools\webpack\src\plugin.js:494:24)
at process._tickCallback (internal/process/next_tick.js:109:7)