Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ng update' does not work with yarn workspaces #14841

Open
pleinonen opened this issue Jun 20, 2019 · 6 comments
Open

'ng update' does not work with yarn workspaces #14841

pleinonen opened this issue Jun 20, 2019 · 6 comments

Comments

@pleinonen
Copy link

@pleinonen pleinonen commented Jun 20, 2019

🐞 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?

No

Description

I am utilizing yarn workspaces -feature in my project. Problem is that I have to keep Angular & AngularCLI dependencies on root packages.json, otherwise 'ng update' command can't figure out the version I currently have. I'd rather keep root package.json clean and move Angular & CLI dependencies to project/package.json to keep things isolated.

Looking at the code, update command resolves dependencies from root package, even when command is executed on package folder. Would it be possible to change behavior in a way that update would first check package dependencies and the fall back to root if nothing is found?

🔬 Minimal Reproduction

  • init yarn workspace project as follows: https://yarnpkg.com/lang/en/docs/workspaces/
  • init angular app with cli and move dependencies from root package.json to workspace-a/package.json (example from previous step)
  • wait until new angular version is available
  • cd to 'workspace-a' and run 'ng update'. Command fails to find any dependencies to update.

🔥 Exception or Error

N/A

🌍 Your Environment


Angular CLI: 8.0.3
Node: 10.15.3
OS: win32 x64
Angular: 8.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.3
@angular-devkit/build-angular     0.800.3
@angular-devkit/build-optimizer   0.800.3
@angular-devkit/build-webpack     0.800.3
@angular-devkit/core              8.0.3
@angular-devkit/schematics        8.0.3
@angular/cli                      8.0.3
@angular/pwa                      0.800.3
@ngtools/webpack                  8.0.3
@schematics/angular               8.0.3
@schematics/update                0.800.3
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

Root package.json:

  "dependencies": {},
  "devDependencies": {
    "npm-run-all": "^4.1.5"
  },

'workspace-a/package.json':

"dependencies": {
    "@angular/animations": "~8.0.1",
    "@angular/common": "~8.0.1",
    "@angular/compiler": "~8.0.1",
    "@angular/core": "~8.0.1",
    "@angular/forms": "~8.0.1",
    "@angular/platform-browser": "~8.0.1",
    "@angular/platform-browser-dynamic": "~8.0.1",
    "@angular/pwa": "^0.800.3",
    "@angular/router": "~8.0.1",
    "@angular/service-worker": "~8.0.1",
    "@auth0/angular-jwt": "^2.1.0",
    "@ngx-translate/core": "^11.0.1",
    ...
    "rxjs": "~6.4.0",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.800.0",
    "@angular/cli": "~8.0.3",
    "@angular/compiler-cli": "~8.0.1",
    "@angular/language-service": "~8.0.1",
    ...
  }

Anything else relevant?

@ngbot ngbot bot added this to the needsTriage milestone Jun 20, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jun 20, 2019
@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Jun 20, 2019

Hi, thanks for opening this, however at the moment this is not supported, and hence I am going to mark it as a feature request.

@laneschmidt
Copy link

@laneschmidt laneschmidt commented Feb 11, 2020

I'm also struggling with this one while trying to upgrade to Angular 9. Is it possible yet?

@andreialecu
Copy link
Contributor

@andreialecu andreialecu commented Feb 25, 2020

I think there may have been some progress here in recent versions because running ng update with no parameters correctly identifies dependencies and what should be updated:

ng update
Using package manager: 'yarn'
Collecting installed dependencies...
Found 142 dependencies.
    We analyzed your package.json, there are some packages to update:
    
      Name                                                   Version                  Command to update
     ----------------------------------------------------------------------------------------------------
      @angular/cdk                                           8.2.3 -> 9.1.0           ng update @angular/cdk
      @angular/material                                      8.2.3 -> 9.1.0           ng update @angular/material

However, the actual update command for a package doesn't work:

ng update @angular/cdk
Using package manager: 'yarn'
Collecting installed dependencies...
Found 142 dependencies.
Package '@angular/cdk' is not a dependency.

Seems like we're almost there. The problem is on this line:

const node = rootDependencies[pkg.name] && rootDependencies[pkg.name].node;

Notice how it says Found 142 dependencies. The .node property is not defined, but the actual dependency is there in the rootDependencies object.

@andreialecu
Copy link
Contributor

@andreialecu andreialecu commented Feb 25, 2020

Possibly relevant: gatsbyjs/gatsby@3b5e41b

Seems like a similar commit in gatsby for resolving issues with yarn workspaces. They replaced read-package-tree with their own implementation.

@ScarletFlash
Copy link

@ScarletFlash ScarletFlash commented Jul 1, 2020

Still relevant.
Trying to upgrade from v9 to v10:

The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via yarn.
Installed packages for tooling via yarn.
Repository is not clean. Update changes will be mixed with pre-existing changes.
Using package manager: 'yarn'
Collecting installed dependencies...
Found 21 dependencies.
Package '@angular/cli' is not a dependency.
@andreialecu
Copy link
Contributor

@andreialecu andreialecu commented Aug 27, 2020

I opened a PR at #18610 to implement this. cc @alan-agius4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.