Repository navigation
'ng update' does not work with yarn workspaces聽#14841
Copy link
Copy link
Open
Labels
area: @angular/clifeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authorsLabel to add when the not a sufficient number of votes or comments from unique authorshotlist: devRelng update DX
Milestone
Description
馃悶 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?
NoDescription
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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: @angular/clifeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authorsLabel to add when the not a sufficient number of votes or comments from unique authorshotlist: devRelng update DX
Activity
alan-agius4 commentedon 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 commentedon Feb 11, 2020
I'm also struggling with this one while trying to upgrade to Angular 9. Is it possible yet?
andreialecu commentedon Feb 25, 2020
I think there may have been some progress here in recent versions because running
ng updatewith no parameters correctly identifies dependencies and what should be updated:However, the actual update command for a package doesn't work:
Seems like we're almost there. The problem is on this line:
angular-cli/packages/angular/cli/commands/update-impl.ts
Line 546 in 9b7b2f0
Notice how it says
Found 142 dependencies. The.nodeproperty is not defined, but the actual dependency is there in therootDependenciesobject.andreialecu commentedon 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 commentedon Jul 1, 2020
Still relevant.
Trying to upgrade from v9 to v10:
andreialecu commentedon Aug 27, 2020
I opened a PR at #18610 to implement this. cc @alan-agius4
5 remaining items
angular-robot commentedon Feb 1, 2022
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
angular-robot commentedon Feb 21, 2022
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
vlio20 commentedon Nov 10, 2023
The issue is happens also in npm workspaces:
#26311
jjgriff93 commentedon Jan 3, 2024
STILL an issue
EinfachHans commentedon Mar 14, 2024
For me it works to temporary remove the dependencies that exist locally in the monorepo from the
package.json, then run the update and then re-add them.Anyways a direct support from angular would be awesome!
Ameni-sbai16 commentedon Jun 20, 2024
Still facing issues while migrating from Angular v16 to v17. Is there still no solution for this?
alydemah commentedon Nov 20, 2024
This issue still exists in Angular v19 this workaround still works though for yarn workspace, update was success.
would be great if this issue be solved.
Thanks
michaelurban commentedon Jan 23, 2025
Throwing sand in the gears here doesn't make much sense.
Angular projects exists in monorepos outside of managed workspaces. That's a fact; it's not going to change. You want this, it means Angular is being used. We're choosing to use Angular but instead of embracing commonly employed and widely accepted practices, Angular is getting in the way. Dictating "the way things should work" rather than accepting reality.
Fix this.
Making people delete their workspace dependencies before an upgrade is a bizarre requirement. Stop.
michaelurban commentedon Jan 28, 2025
I ended up switching to pnpm for my package manager and using pnpm-workspace.yaml to define my workspace.
angular.json:pnpmworkspace deps can be referenced inpackage.jsonwithout issue.package.json:ng updateoutput:muuvmuuv commentedon Feb 4, 2025
@michaelurban how did you get the update running I get
Error: This command is not available when running the Angular CLI outside a workspace.in the monorepo root.