The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.8.3 was found instead

前端 未结 9 1251
失恋的感觉
失恋的感觉 2020-12-24 05:25

I starting getting this error on my Angular app:

The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.8.3 was found instead

相关标签:
9条回答
  • 2020-12-24 05:40

    I did next steps:

    • removed package-lock.json;
    • npm install -g --save typescript@2.7.2;
    • npm uninstall -g --save typescript@2.9.2;
    • in package.json, section "devDependencies" updated string with typescript as "typescript": "~2.7.2".

    After all above run in project's terminal ng serve --open (I've been using IDEA 2018.1).

    0 讨论(0)
  • 2020-12-24 05:41

    This is just because in your projects package.json file has

    eg."devDependencies": {"typescript": "~2.8.3" }

    and in your machine where angular cli installed has "typescript": "2.7.2" version.

    You can check this by ng -v or ng v.

    So, just open package.json update your typescript version and run npm install and you are done.

    0 讨论(0)
  • 2020-12-24 05:43

    Installing "@angular/compiler-cli": "7.0.0-beta.4" resolved this issue. I use "typescript": "3.0.3".

    0 讨论(0)
  • 2020-12-24 05:46

    Downgrading to typescript 2.9.2 (npm install typescript@2.9.2) and re-running ng update --all still yields the error (twice):

    Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.1.3"
    Verified that version 2.9.2 of typescript was in node_modules.
    
    0 讨论(0)
  • 2020-12-24 05:49

    Had the same issue (amongst many others) after updating to macOS Mojave. Fixed it by removing node_modules and package_lock.json manually, changed in package.json from "typescript": "~2.7.2" to "typescript": "~2.8.0" and ran npm install.

    0 讨论(0)
  • I did the following:

    • Delete manually the folder node_modules
    • Delete manually the file package-lock.json
    • In the file package.json be sure to set the dependence of TypeScript as

       "typescript": "2.7.2"
      
    • run npm cache clean -f

    • run npm install

    That work for me.

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