-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Command
update
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
While migrating a project from angular 19 to angular 20 that uses angular-eslint, the migration of angular-eslint crashed. See the following sections for what "crashed" means in detail and how to reproduce it. I'm not going to repeat it here.
Minimal Reproduction
Run this Dockerfile to reproduce the issue:
FROM node:22
RUN node --version
RUN npm --version
RUN npx @angular/cli@19 new demo --ssr false --skip-git --style css
WORKDIR demo
RUN npx ng add angular-eslint@19 --skip-confirmation
RUN npm install typescript-eslint@^8.0.0
RUN npx ng update @angular/cli@20 @angular/core@20
RUN npm ls @angular-devkit/schematics
RUN grep '"version"' node_modules/@angular-devkit/schematics/package.json
RUN npx ng update angular-eslint@20 || true
RUN npm ls @angular-devkit/schematics
RUN grep '"version"' node_modules/@angular-devkit/schematics/package.json
Exception or Error
✖ Migration failed: Cannot find module '../package-manager/executor'
Require stack:
- /demo/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tasks/node/index.js
- /demo/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/workflow/node-workflow.js
- /demo/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /demo/node_modules/@angular/cli/src/commands/update/cli.js
- /demo/node_modules/@angular/cli/src/commands/command-config.js
- /demo/node_modules/@angular/cli/src/command-builder/command-runner.js
- /demo/node_modules/@angular/cli/lib/cli/index.js
- /demo/node_modules/@angular/cli/lib/init.js
See "/tmp/ng-E8vcjp/angular-errors.log" for further details.
Your Environment
I am upgrading a minimal package from Angular 19.8.1 to 20.7.0. Also these versions (printed from running the Dockerfile) may be relevant:
STEP 2/13: RUN node --version
v22.21.1
STEP 3/13: RUN npm --version
10.9.4
Anything else relevant?
The issue is caused by npm relocating @angular-devkit/schematics@20 from node_modules/@angular/cli/node_modules/@angular-devkit/schematics to node_modules/@angular-devkit/schematics after @angular-devkit/schematics/tasks/node/index.js has been loaded, but before the require("../package-manager/executor") is executed. The full run of the ng update command is:
STEP 11/13: RUN npx ng update angular-eslint@20 || true
> [email protected] ng
> ng update angular-eslint@20
Using package manager: npm
Collecting installed dependencies...
Found 24 dependencies.
Fetching dependency metadata from registry...
Updating package.json with dependency angular-eslint @ "20.7.0" (was "19.8.1")...
UPDATE package.json (1123 bytes)
❯ Cleaning node modules directory
✔ Cleaning node modules directory
❯ Installing packages
✔ Installing packages
** Executing migrations of package 'angular-eslint' **
❯ Updates @angular-eslint to v20.
UPDATE package.json (1123 bytes)
✖ Migration failed: Cannot find module '../package-manager/executor'
Require stack:
- /demo/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tasks/node/index.js
- /demo/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/workflow/node-workflow.js
- /demo/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /demo/node_modules/@angular/cli/src/commands/update/cli.js
- /demo/node_modules/@angular/cli/src/commands/command-config.js
- /demo/node_modules/@angular/cli/src/command-builder/command-runner.js
- /demo/node_modules/@angular/cli/lib/cli/index.js
- /demo/node_modules/@angular/cli/lib/init.js
See "/tmp/ng-E8vcjp/angular-errors.log" for further details.
note that angular-eslint and @angular-eslint/schematics were the last packages to depend on @angular-devkit/schematics@19, so npm decided to drop @angular-devkit/schematics@19 from the root directory in node_modules, and move @angular-devkit/schematics@20 there. See the npm ls output before the upgrade:
STEP 9/13: RUN npm ls @angular-devkit/schematics
[email protected] /demo
+-- @angular/[email protected]
| +-- @angular-devkit/[email protected]
| `-- @schematics/[email protected]
| `-- @angular-devkit/[email protected]
`-- [email protected]
+-- @angular-devkit/[email protected]
`-- @angular-eslint/[email protected]
`-- @angular-devkit/[email protected] deduped
STEP 10/13: RUN grep '"version"' node_modules/@angular-devkit/schematics/package.json
"version": "19.2.19",
and after the failed update attempt (note that the package was successfully updated by ng update/npm, just the migration script crashed afterwards):
STEP 12/13: RUN npm ls @angular-devkit/schematics
[email protected] /demo
+-- @angular/[email protected]
| +-- @angular-devkit/[email protected]
| `-- @schematics/[email protected]
| `-- @angular-devkit/[email protected] deduped
`-- [email protected]
+-- @angular-devkit/[email protected] deduped
`-- @angular-eslint/[email protected]
`-- @angular-devkit/[email protected] deduped
STEP 13/13: RUN grep '"version"' node_modules/@angular-devkit/schematics/package.json
"version": "20.3.12",
I already tried to report the issue to angular-eslint, as it was the update/migration process of angular-eslint that failed, but the issue got "closed as not planned" because I am supposed to update angular-eslint at the same time as angular according to the author of angular-eslint, see: angular-eslint/angular-eslint#2807
I then tried to report the issue to angular as documentation issue, because the documentation mentions in no way that upgrading further packages at the same time as the angular core framework migth be required. This issue also got "closed as not planned", because angular recommends to not upgrade third-party packages at the same time as the framework, but recommends a step-by-step upgrade, see angular/angular#65692
Noten that the issue is usually only observable in a step-by-step upgrade process, because only in that case @angular/schematics will first be installed as local dependency for @angular-cli and then moved in the last step of the upgrade, but the issue is not observable if everything is upgraded at once. Actually, I am unsure whether the issue is within @angular/cli, or angular-eslint is mis-using the angular upgrade process or specifies dependencies in a way that are not supported by the Angular project. If you can pinpoint a specific way angular-eslint is using angular wrong (or in an unsupported way), I am ready to report another issue and possibly a merge request to angular-eslint.