npm / npm/cli

[BUG] Dependency alias breaks local `npm install`

Open
#8,223 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug config:aliases Documentation Priority 2
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

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

I have two local packages, foo and bar, packed into separate .tgz files. bar depends on foo.

  • I install foo
  • I install bar
  • ✅ Success. npm just uses the already-installed foo.

Now I update bar to depend on foo with a package alias:

  • I install foo
  • I install bar
  • ❌ Error loading bar from npmjs.org. (It is not, and will not be, there)
Expected Behavior

I would expect both of the above scenarios to result in a successful package install.

Steps To Reproduce

Bug reproduction and instructions here:
https://github.com/NfNitLoop/bug-npm-alias-breaks-local-install

Environment
  • npm: 11.3.0
  • Node.js: v23.7.0
  • OS Name: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 arm64
  • System Model Name: Macbook pro
  • npm config:
; "builtin" config from /opt/homebrew/lib/node_modules/npm/npmrc

prefix = "/opt/homebrew"

; node bin location = /opt/homebrew/Cellar/node/23.7.0/bin/node
; node version = v23.7.0
; npm local prefix = /Users/codycasterline/code/bug-npm-alias-breaks-local-install
; npm version = 11.3.0
; cwd = /Users/codycasterline/code/bug-npm-alias-breaks-local-install
; HOME = /Users/codycasterline
; Run `npm config ls -l` to show all defaults.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and run its instructions using the two local .tgz packages. Compare installation with the direct dependency and the package alias; done means both local installation scenarios succeed without trying to load bar's dependency from npmjs.org.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.