在命令行中为angular-cli生成的项目运行ng serve
时,我收到以下错误:
ERROR in Cannot read property 'listLazyRoutes' of undefined
有关如何解决此错误的任何想法?
答案 0 :(得分:15)
将angular-cli更新为最新版本:npm install -g angular-cli @ latest
在我的特定情况下,我将package.json更新为:
"dependencies": {
"@angular/common": "^2.4.0",
"@angular/compiler": "^2.4.0",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"@angular/http": "^2.4.0",
"@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.4.0",
"@angular/router": "~3.4.0",
"core-js": "^2.4.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.24",
"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-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.0.2",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.5"
}
使用此package.json内容执行npm install,它将起作用。
答案 1 :(得分:5)
我能够通过将angular-cli生成的项目升级到angular-cli: 1.0.0-beta.24
来解决问题。如果您从以前的版本生成项目(例如,在我的情况下为* -beta.22),请通过运行以下命令升级本地项目包(dev依赖项):
>rm -rf node_modules dist tmp
>npm install --save-dev angular-cli@latest
>npm install
>ng init
要升级到新的angular-cli,请在命令行中运行以下命令:
>npm uninstall -g angular-cli
>npm cache clean
>npm install -g angular-cli@latest
2017年2月23日更新:语法在获取最新的angular-cli时发生了变化。请改用以下命令:
npm install --save-dev @angular/cli@latest
答案 2 :(得分:0)
这对我有用 ERROR in Cannot read property 'listLazyRoutes' of undefined
但我还需要重新安装@ angular / core
答案 3 :(得分:0)
我遇到了类似的错误:
<块引用>发生未处理的异常:无法读取的属性“B” 未定义。
所以我更新了我的 angular cli
、核心和编译器版本:
ng update
然后我从 here 安装了最新的 node.js LTS
版本,这解决了我的问题。