Angular-cli: ng-add doesn't install the latest version correctly

Created on 20 Feb 2020  Β·  9Comments  Β·  Source: angular/angular-cli

🐞 Bug report

Command (mark with an x)


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

Is this a regression?

Yes. With @angular/cli@8 doesn't cause that error.

Description

In a project created by @angular/cli@latest, ng add command seems not working correctly.
Executing ng add @ngrx/store, it throws an error.

$ ng add @ngrx/store
Installing packages for tooling via yarn.
Installed packages for tooling via yarn.
The package that you are trying to add does not support schematics. You can try using a different version of the package or contact the package author to add ng-add support.
error Command failed with exit code 1.

But adding @latest to the @ngrx/store, it installs and runs schematics of @ngrx/store.

ng add @ngrx/store@latest
Package has unmet peer dependencies. Adding the package may not succeed.
Installing packages for tooling via yarn.
Installed packages for tooling via yarn.
CREATE src/app/reducers/index.ts (359 bytes)
UPDATE src/app/app.module.ts (715 bytes)
UPDATE package.json (1349 bytes)
βœ” Packages installed successfully.
✨  Done in 6.67s.

It seems Angular CLI's bug in ng add command.

πŸ”¬ Minimal Reproduction

  1. Create new project with the latest CLI (npx @angular/cli@latest new my-app)
  2. Execute ng add @ngrx/store in the project.

πŸ”₯ Exception or Error


$ ng add @ngrx/store
Installing packages for tooling via yarn.
Installed packages for tooling via yarn.
The package that you are trying to add does not support schematics. You can try using a different version of the package or contact the package author to add ng-add support.
error Command failed with exit code 1.

🌍 Your Environment


Angular CLI: 9.0.3
Node: 12.13.0
OS: darwin x64

Angular: 9.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.3
@angular-devkit/build-angular     0.900.3
@angular-devkit/build-optimizer   0.900.3
@angular-devkit/build-webpack     0.900.3
@angular-devkit/core              9.0.3
@angular-devkit/schematics        9.0.3
@angular/cli                      9.0.3
@ngtools/webpack                  9.0.3
@schematics/angular               9.0.3
@schematics/update                0.900.3
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2


Anything else relevant?

angulacli low confusing docs

Most helpful comment

For others trying to use Angular v9 with NgRx v8, use the @latest tag when using ng add to get the latest released version according to npm. The Angular CLI tries to figure out the version to install, taking into account the peer dependencies. This is why NgRx 1.2.1 is being chosen without using the @latest tag. This issue is not present if you are installing NgRx v9 after it goes final.

ng add @ngrx/store@latest

All 9 comments

Hi @lacolaco, the problem seems to be that @ngrx/store version 8 is not compatible with Angular 9. This is due that the peerDependencies for this package are the following;

"peerDependencies": {
   @angular/core": "^8.0.0",
  "rxjs": "^6.4.0"
},

ng-add will try to find a compatible version and version 1.2.1 has no peerDependencies which is making it the package valid to be used.

//cc @brandonroberts

Facing a similar issue with a current project on v9. Any update?

@Brian611 This is a problem with the @ngrx/store package. It does not currently support Angular version 9.

For others trying to use Angular v9 with NgRx v8, use the @latest tag when using ng add to get the latest released version according to npm. The Angular CLI tries to figure out the version to install, taking into account the peer dependencies. This is why NgRx 1.2.1 is being chosen without using the @latest tag. This issue is not present if you are installing NgRx v9 after it goes final.

ng add @ngrx/store@latest

@brandonroberts Yes i noticed and upgraded but would've hoped this would be a fix rather than waiting on ngrx v9 cause now we running prod project on an rc version of ngrx which is not ideal.

@Brian611 although not officially supported by us, there's nothing preventing you from running NgRx v8 with Angular v9. There's only the peer dependency warning. NgRx v9 will be out soon

@brandonroberts ohk cool.

Closing as this is working as expected.

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

Was this page helpful?
0 / 5 - 0 ratings