Skip to content

[BUG] Custom Registry Path Omitted when Package Name Starts with Name of PathΒ #8736

@flj2mu2

Description

@flj2mu2

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

In our setup, we are using a custom registry configured via a setting in the npmrc file:

registry = https://<our-registry-host>/npm/

Some of our projects have a dev dependency that has a name starting with npm (namely npm-run-path). When running npm i or npm ci on such a project while using the custom registry, we get the following error:

npm error 404 Not Found - GET https://<our-registry-host>/npm-run-path/-/npm-run-path-4.0.1.tgz

The resolved URL to fetch the tarball via the custom registry is missing the path part npm.

This happens with npm 11.6.2. We have traced back that the bug was introduced with 11.3.0 and partially fixed in 11.4.0 (with this commit).

This resolution issue seems a bit similar to issue 8720.

Expected Behavior

The URL get correctly resolved to https://<our-registry-host>/npm/npm-run-path/-/npm-run-path-4.0.1.tgz

Steps To Reproduce

  1. In this environment...
    package.json
{
  "name": "npm-bug-example",
  "version": "1.0.0",
  "description": "",
  "license": "ISC",
  "author": "",
  "type": "commonjs",
  "main": "index.js",
  "scripts": {},
  "dependencies": {
    "axios": "1.13.2",
    "npm-run-path": "6.0.0"
  }
}

compose.yml

services:
  nginx:
    image: nginx:alpine
    container_name: npm-proxy
    ports:
      - "3080:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    restart: unless-stopped

nginx.conf

events {}

http {
    resolver 8.8.8.8 8.8.4.4;

    server {
        listen 80;

        location /health {
            return 200 "healthy\n";
        }

        location /npm/ {
            rewrite ^/npm/(.*)$ /$1 break;
            proxy_pass https://registry.npmjs.org;
            proxy_ssl_server_name on;
            proxy_set_header Host registry.npmjs.org;
        }

        location / {
            return 404 "Not found. Use /npm/* to proxy to npm registry.\n";
        }
    }
}
  1. With this config...
    .npmrc
registry = http://localhost:3080/npm/
cache = ./npm

  1. Run 'npm i --verbose'
  2. Get the following error:
npm error code E404
npm error 404 Not Found - GET http://localhost:3080/npm-run-path/-/npm-run-path-6.0.0.tgz
npm error 404
npm error 404  The requested resource 'npm-run-path@http://localhost:3080/npm-run-path/-/npm-run-path-6.0.0.tgz' could not be found or you do not have permission to access it.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.

It will work properly for the axios dependency when npm-run-path is removed. It will also work properly when not using the local registry.

Environment

  • npm: 11.6.2
  • Node.js: 24.11.0
  • OS Name: macOS 26.1
  • System Model Name: Macbook Pro
  • npm config:
registry = https://<our-registry-host>/npm/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions