angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.79k stars 11.98k forks source link

Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.1.1 <3.3", would install "3.4.5"). #14561

Closed jtsom closed 5 years ago

jtsom commented 5 years ago

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [X] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes

Yes, the previous version in which this bug was not present was: .... ### Description Having this issue trying to do an ng update on a pretty stock angular 7 application to angular 8: ``` ng update @angular/cli Your global Angular CLI version (8.0.0) is greater than your local version (7.3.8). The local Angular CLI version is used. To disable this warning use "ng config -g cli.warnings.versionMismatch false". Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.1.1 <3.3", would install "3.4.5"). Incompatible peer dependencies found. See above. ``` package.json: ``` { "name": "sample-player", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "~7.2.0", "@angular/common": "~7.2.0", "@angular/compiler": "~7.2.0", "@angular/core": "~7.2.0", "@angular/forms": "~7.2.0", "@angular/platform-browser": "~7.2.0", "@angular/platform-browser-dynamic": "~7.2.0", "@angular/router": "~7.2.0", "core-js": "^2.5.4", "rxjs": "~6.3.3", "tslib": "^1.9.0", "videogular2": "^6.4.0", "zone.js": "~0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.13.0", "@angular/cli": "~7.3.8", "@angular/compiler-cli": "~7.2.0", "@angular/language-service": "~7.2.0", "@types/node": "~8.9.4", "@types/jasmine": "~2.8.8", "@types/jasminewd2": "~2.0.3", "codelyzer": "~4.5.0", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.0.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~1.1.2", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.11.0", "typescript": "~3.2.2" } } ``` ## πŸ”¬ Minimal Reproduction

πŸ”₯ Exception or Error





🌍 Your Environment





jtsom commented 5 years ago

Also, do we have to do a git commit after every update operation??

ng update @angular/core
Repository is not clean.  Please commit or stash any changes before updating.
alan-agius4 commented 5 years ago

Also related to https://github.com/angular/angular-cli/issues/13095

@jtsom, you can run multiple migrations as such: ng update @angular/cli @angular/core

jtsom commented 5 years ago

I did see #13095 but wanted to specifically target the new 8.0 (where it says it supports Typescript 3.4 - except where it doesn't....)

jtsom commented 5 years ago

I was able to get the update to run using the --force flag, but it looks like the operations that are run after the update (updating tsconfig.json, tslint.json, etc) were not run. How do I re-run those schematics to get everything up to date?

alan-agius4 commented 5 years ago

You can run ng update @angular/cli--from 7 --to 8 --migrate-only

jtsom commented 5 years ago

Except:

ng update @angular/cli --from 7 --to 8 --migrate-only
Using package manager: 'npm'
Collecting installed dependencies...
Found 32 dependencies.
Invalid Version: 7
alan-agius4 commented 5 years ago

@jtsom, yeah there is another issue with command, kindly see https://github.com/angular/angular-cli/issues/14559#issuecomment-496933988

marc-wilson commented 5 years ago

Ran into this as well. The only way I could get angular to upgrade 8 (from 7) was to use npm install @angular/cli@8.0.0 --save-dev (opposed to ng update @angular/cli

once I did this, I ran into the issue @jtsom called out:

Repository is not clean. Please commit or stash any changes before updating.

Once I committed the changes and ran ng update --all, I get more warnings:

Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1")
                  Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=3.1 < 3.5", would install "3.5.1")
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1").
Incompatible peer dependencies found. See above.
tc9011 commented 5 years ago

@mswilson4040 same problem, Finally I use npm to update angular, like this:

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

npm install @angular/{common,compiler,compiler-cli,core,forms,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@3.4 --save

After update, you should manually add parameter to ViewChild or ContentChild

alan-agius4 commented 5 years ago

Hi, are you running ng update @angular/cli @angular/core? You need to update both the CLI and the framework at the same time.

tc9011 commented 5 years ago

@alan-agius4 yes, I run ng update @angular/cli at first, and it worked well, but after I run ng update @angular/core , it said Repository is not clean. Please commit or stash any changes before updating image

kswarthout commented 5 years ago

I encountered the same issues. The warning is related to your git repo. Committing my recent changes fixed the problem, and I was able to run the ng update commands (i.e. ng update @angular/cli @angular/core)

TomySmit commented 5 years ago

run this command git status --porcelain and add files and directories to ignore file or commit

RogierdeRuijter commented 5 years ago

run this command git status --porcelain and add files and directories to ignore file or commit

Fixing my git ignore worked for me.

huyinghuan commented 5 years ago
npm install -g @angluar/cli
ng update --all --force
ng add @angular/http 

it work fine for ng server and ng build

damingerdai commented 5 years ago

i also meet this error. first,i run

ng update @angular/core

and them

ng update @angular/cli

i don't run

ng update rxjs

now i have upgraded to angular8 and every thing sees ok. i hope it is helpful

KylerJohnson26 commented 5 years ago

I had the same errors. Here's what worked for me:

I ran the following to update the global version of the Angular CLI: npm i -g @angular/cli@8.0.0

Then I ran the following to update my angular project: ng update --all --force

Note: It's important to have a clean, up-to-date repo before running trying to update

tc9011 commented 5 years ago

run this command git status --porcelain and add files and directories to ignore file or commit

Before you use ng update, you should commit or stash all files

Laurens-makel commented 5 years ago

i also meet this error. first,i run

ng update @angular/core

and them

ng update @angular/cil

i don't run

ng update rxjs

now i have upgraded to angular8 and every thing sees ok. i hope it is helpful

Thanks, seems to be working! Btw, you made a little spelling mistake in your ng update @angular/cil command, it should be ng update @angular/cli

matheo commented 5 years ago

On a side note, I had to run ng update @angular/material --from 7 --to 8 --migrate-only multiple times, committing the changes and trying again, because it was throwing FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory after editing my import paths on tons of components.

Thanks for the great work tho!

damingerdai commented 5 years ago

i also meet this error. first,i run

ng update @angular/core

and them

ng update @angular/cil

i don't run

ng update rxjs

now i have upgraded to angular8 and every thing sees ok. i hope it is helpful

Thanks, seems to be working! Btw, you made a little spelling mistake in your ng update @angular/cil command, it should be ng update @angular/cli

Thanks

jtsom commented 5 years ago

Just tried to update another project and got:

ng update @angular/cli @angular/core @angular/cdk @angular/material
Your global Angular CLI version (8.0.1) is greater than your local
version (7.1.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
                  Package "@ncstate/sat-popover" has an incompatible peer dependency to "@angular/cdk" (requires "^7.0.0", would install "8.0.0").
Incompatible peer dependencies found. See above.

getting worse...

fr0 commented 5 years ago

What's the solution for this? Running ng update --all gives a bunch of errors.

                  Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=3.1 < 3.5", would install "3.5.1")
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1")
                  Package "ng-packagr" has an incompatible peer dependency to "typescript" (requires ">=2.7 < 3.5", would install "3.5.1")
                  Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=3.1 < 3.5", would install "3.5.1").
Incompatible peer dependencies found. See above.
marc-wilson commented 5 years ago

I've never actually seen ng update --all work. I was able to get things working by doing ng update @angular/core @angular/cli

fr0 commented 5 years ago

If ng update --all doesn't work, then it should be removed.

Or at the very least, this message should be changed:

 We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cli                       7.3.9 -> 8.0.1           ng update @angular/cli
      @angular/core                      7.2.15 -> 8.0.0          ng update @angular/core

    There might be additional packages that are outdated.
    Run "ng update --all" to try to update all at the same time.
marc-wilson commented 5 years ago

Yea, it's immediately suspicious when it reads Run "ng update --all" to _try_ to update all at the same time.

astronaute77 commented 5 years ago

Also having the same issue when running ng update --all:

Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1").

Random90 commented 5 years ago

Same here, ng update --all throws typescript dependency error, but ng update @angular/core @angular/cli worked.

kishore0207 commented 5 years ago

Am updating the angular 7 to 8, after updating the ng update @angular/cli @angular/core command updated successfully, but after updating the material through ng update @angular/material entered, then i got the error. Repository is not clean. Please commit or stash any changes before updating.

deeja commented 5 years ago

Repository is not clean. Please commit or stash any changes before updating.

Commit the changed files into your git repository and the message will disappear. Likely an enforced checkpoint

Kolahzary commented 5 years ago

It also happened to me, solved it by these steps

  1. remove node_modules and package-lock.json
  2. ng update @angular/core
  3. ng update @angular/cli
salemdar commented 5 years ago

The problem is, usually Angular follows new Typescript releases from a few months behind and once there is a new Typescript version, ng update --all becomes unusable. The only solutions that I can think are adding an option to:

madalinignisca commented 5 years ago

yarn add -D typescript@~3.4.0 sorted the problem.

For the moment, typescript will be updated to latest patch on 3.4.x versions. When Angular will allow latest stable typescript, I will update again it using the same command for the new supported minor version.

alan-agius4 commented 5 years ago

Duplicate of https://github.com/angular/angular-cli/issues/13095

Sirjiskit commented 5 years ago

I once face the same issue was www.allovermyhead.com tried almost every thing getting one error of the other then i tried ng update --all --force; Done evering was alright.

marc-wilson commented 5 years ago

Seems like ng update is just getting more finicky and fragile with every release.

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.