Getting error on ng serve: ERROR in Cannot read property 'listLazyRoutes' of undefined

前端 未结 3 380
迷失自我
迷失自我 2020-12-30 05:24

When running ng serve in command-line for an angular-cli generated project, I am getting error below:

 ERROR in Cannot read property \'listLazy         


        
相关标签:
3条回答
  • 2020-12-30 05:38

    Update angular-cli to latest: npm install -g angular-cli@latest

    And in my particular case, I updated the package.json to this:

    "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"
      }
    

    Perform npm install with this package.json content and it'll work.

    0 讨论(0)
  • 2020-12-30 05:39

    This worked for me ERROR in Cannot read property 'listLazyRoutes' of undefined

    But I also needed to re install my @angular/core

    0 讨论(0)
  • 2020-12-30 05:56

    I was able to fix the issue by upgrading the angular-cli generated project to angular-cli: 1.0.0-beta.24. If you generated the project from previous version (eg. *-beta.22 in my case), upgrade the local project package(dev dependencies) by running commands below:

    >rm -rf node_modules dist tmp
    >npm install --save-dev angular-cli@latest
    >npm install
    >ng init
    

    To upgrade to new angular-cli, run commands below in the command-line:

    >npm uninstall -g angular-cli
    >npm cache clean
    >npm install -g angular-cli@latest
    

    Update on 2/23/2017: Syntax changed in getting latest angular-cli. Use command below instead:

    npm install --save-dev @angular/cli@latest

    0 讨论(0)
提交回复
热议问题