Module build failed: TypeError: Cannot read property 'newLine' of undefined

前端 未结 7 879
春和景丽
春和景丽 2021-01-17 16:26

Everything was running fine yesterday, now when I try to ng serve I get these errors:

ERROR in ./src/main.ts Module build failed: TypeError

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-17 16:55

    So none of the install @angular/cli@latest worked for me, most likely will work in the future I presume.

    I had another angular2 project which was ng serve-ing fine. So I just copied the package.json dependencies from it and updated the angular-cli.json.

    And now it works again!

    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/cli": "1.0.0-beta.31",
        "@angular/compiler-cli": "^2.4.0",
        "@types/jasmine": "2.5.38",
        "@types/node": "^6.0.42",
        "codelyzer": "~2.0.0-beta.1",
        "css-loader": "^0.26.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-istanbul-reporter": "^0.2.0",
        "karma-jasmine": "^1.0.2",
        "node-sass": "^4.5.0",
        "node-sass-import": "^1.1.1",
        "protractor": "~5.1.0",
        "sass-loader": "^6.0.0",
        "source-map-loader": "^0.1.6",
        "ts-node": "1.2.1",
        "tslint": "^4.3.0",
        "typescript": "~2.0.0"
      }
    

    angular-cli.json

    Had to revert back to the older type of "source" key

    "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
    }
    

提交回复
热议问题