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

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 20:07:21
myhouse

You should do npm install typescript@'>=2.7.2 <2.8.0'. This will install the correct typescript your project needs. Make sure you run this inside your Angular project.

On Windows, you should use double quotes instead of single quotes, like so:

npm install typescript@">=2.7.2 <2.8.0"

Otherwise, you'll get The system cannot find the file specified..

In your project folder run again npm install typescript@2.7.2 as stated from here:

Want to upgrade project from Angular v5 to Angular v6

Then it should work.

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).

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.

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

Prakash Kumar Behera

To upgrade, run the following commands in the terminal.

  • Install the latest version of NPM

    npm install npm@latest -g
    
  • Run audit

    npm audit  
    
  • Update the NPM

    npm update
    
  • Run the NPM run script.

    npm start
    

Now your compiler is ready.

Vipisanan

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.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!