npm / npm/cli

[BUG] npm 9.2.0 fails to resolve local dependencies specified by workspace asterisk glob with Node 18/19

Open
#5,958 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage Release 9.x
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
Version

v19.2.0

Platform

Darwin MBP 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

I have something like the following directory structure

.
├── LICENSE
├── README.md
├── docs
├── examples
├── jest.config.js
├── node_modules
├── package-lock.json
├── package.json
├── packages
│   ├── core
│   ├── dep_a
│   └── dep_b
├── tsconfig.build.json
└── tsconfig.json

Within the core package I have a package.json that specifies local dependencies like the following example:

{
  "dependencies": {
    "@somescope/dep_a": "*",
    "@somescope/dep_b": "*",
    "yargs": "^17.6.2"
  },
}
How often does it reproduce? Is there a required condition?
What do you see instead?

With the earlier mentioned project setup and doing a npm install for one of our test cases in the examples folder that does e.g.: a require("@somescope/dep_a"); we're running into this:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@somescope%2fdep_a - Not found
npm ERR! 404 
npm ERR! 404  '@somescope/dep_a@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
Expected Behavior

The install works just fine as expected

Steps To Reproduce

Reproduces 100% of the time when using Node v19.2.0/v18.12.1 and the above setup.
It seems to work fine with Node v16.18.1

Environment
  • npm: 9.2.0
  • Node.js: v18.12.1/v19.2.0
  • OS Name: Darwin
  • System Model Name: MacbookPro M1 arm64
  • npm config:
; "cli" config from command line options

location = "project" 

; node bin location = /Users/<user>/.nvm/versions/node/v19.2.0/bin/node
; node version = v19.2.0
; npm local prefix = /Users/<user>/Git/work/<project>/examples/custom-hooks
; npm version = 9.1.3
; cwd = /Users/<user>/Git/work/<project>/examples/custom-hooks
; HOME = /Users/<user>
; 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

Reproduce the failure with the package.json workspace layout and npm install in examples/custom-hooks, comparing Node 16 with Node 18/19. Trace the local dependency resolution from that package.json and verify completion when @somescope/dep_a and @somescope/dep_b resolve locally without an E404 registry request.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.