Skip to content

ng update not resolving the correct NPM package when using npm:<name> syntax as version range #25224

Open
@jordimarimon

Description

@jordimarimon

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

I searched through the issues and I did found some related issues but they weren't exactly the same:

Feel free to close this issue if you fill like it's a duplicate of another one.

I wanted to update my angular project to the latest version and I executed the command:

ng update @angular/cli @angular/core

In my project I have as a development dependency @types/web (TypeScript DOM declaration files) because I have private libraries that use my applications and I like to make sure that all my projects use the same version of declaration files and also I like to decouple the TypeScript compiler version from the declaration files version.

The dependecy in the package.json looks like the following:

"@typescript/lib-dom": "npm:@types/web@^0.0.99"

You can see that the package hosted in NPM registry is @types/web but the name of the dependency store in node_modules is @typescript/lib-dom.

It's this way because TypeScript will search in /node_modules/@typescript/lib-dom to know if the declaration files have been installed independently. If the folder is not present, it will use the declaration files that come with the TypeScript compiler (/node_modules/typescript/lib/lib.dom.d.ts).

When I execute the ng update command, I get the following error:

✔ Packages successfully installed.
Using package manager: npm
Collecting installed dependencies...
Found 16 dependencies.
Fetching dependency metadata from registry...
✖ Migration failed: 404 Not Found - GET https://registry.npmjs.org/@typescript%2flib-dom - Not found
  See ".../angular-errors.log" for further details.

Basically, the Angular CLI is trying to fetch @typescript/lib-dom but this is not the name of the package, the correct name to fetch is @types/web.

Minimal Reproduction

I have created the following repository that reproduces the issue.

You don't need to clone it, you can follow the steps explained in the README.md:

https://github.com/jordimarimon/angular-cli-update-issue

Exception or Error

[error] HttpErrorGeneral: 404 Not Found - GET https://registry.npmjs.org/@typescript%2flib-dom - Not found
    at /tmp/angular-cli-packages-Fv6UlW/node_modules/npm-registry-fetch/lib/check-response.js:95:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RegistryFetcher.packument (/tmp/angular-cli-packages-Fv6UlW/node_modules/pacote/lib/registry.js:87:19)
    at async Promise.all (index 3)
    at async /tmp/angular-cli-packages-Fv6UlW/node_modules/@angular/cli/src/commands/update/schematic/index.js:671:36
    at async callRuleAsync (/tmp/angular-cli-packages-Fv6UlW/node_modules/@angular-devkit/schematics/src/rules/call.js:77:18)

Your Environment

Angular CLI: 15.2.8
Node: 18.12.1
Package Manager: npm 9.5.1
OS: linux x64

Angular: 15.2.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1502.8
@angular-devkit/build-angular   15.2.8
@angular-devkit/core            15.2.8
@angular-devkit/schematics      15.2.8
@angular/cli                    15.2.8
@schematics/angular             15.2.8
rxjs                            7.8.1
typescript                      4.9.5

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions