Skip to content

Upgrading angular-eslint after upgrading angular core fails migration #2807

@karcherm

Description

@karcherm

Description and reproduction of the issue

Run this dockerfile:

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

The relevant version information from running this dockerfile is:

STEP 2/13: RUN node --version
v22.21.1
STEP 3/13: RUN npm --version
10.9.4

The output of the final command, ng update angular-eslint@20 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.

Versions

package version
angular-eslint 19.8.1 -> 20.7.0
node 22.21.1
npm 10.9.4

Further information

I actually think I identified the root cause, which is in the infrastructure used by angular-eslint. That's why the Dockerfile contains the npm ls calls. Before the attempted upgrade of angular-eslint, we get this output:

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",

The package @angular-devkit/schematics is installed in version 19.2.19 at the root of the workspace, and it is installed in version 20.3.12 in the subtrees for @angular/cli and @schematics/angular. While ng update angular-eslint@20 runs, the last remaining dependency on @angular-devkit/[email protected] is uninstalled, and @angular-devkit/[email protected] gets promoted to the root of the workspace. After the failed migration, the output looks like this:

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",

The effect of promoting @angular-devkit/[email protected] to the root of the workspace is that lazy loading of additional Javascript files from @angular-devkit/[email protected] no longer works, because the files are no longer found where other parts of the package were previously loaded from. Note this specific part of the error message:

✖ Migration failed: Cannot find module '../package-manager/executor'
Require stack:
- /demo/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tasks/node/index.js

The requiring Javascript file has been loaded from the private 20.3.12 copy of @angular-devkit/schematics located inside the @angular/cli folder. During the upgrade of angular-eslint and @angular-eslint/schematics to 20.7.0, @angular-devkit/[email protected] was relocated to /demo/node_module/@angular-devkit/schematics, so the path /demo/node_module/@angular/cli/node_modules/@angular-devkit/schematics/tasks/package-manager/executor.js no longer exists.

It's thus quite clear that the root cause is somewhere within the ng upgrade infrastructure invoking npm in a way that it can relocate modules that are used in the ng upgrade process, but as I have no idea where exactly I should report the issue, or whether angular-eslint is actually misusing the migration code, I'm filing the issue on the project that makes the issue surface. Feel free to push the issue to a lower level.

EDIT: Updated the Dockerfile at the start to the version that was actually used while reporting the issue and replaced npm run ng -- by npx ng to improve readablity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions