Skip to content

[BUG] npm init does not use locally installed version of given package. #7700

@anthonyjpratti

Description

@anthonyjpratti

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

npm init @repo -w package/foo will fail due to the following error.

npm error code E404
npm error 404 Not Found - GET https://<redacted>/api/npm/npm-<redacted>//@repo%2fcreate
npm error 404
npm error 404  '@repo/[email protected]' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.

The @repo/create package is a local package and installed as a dependency on the workspace root.

Expected Behavior

npm init @repo -w package/foo succeeds as mkdir package/foo; cd package/foo; npx @repo/create does.

Steps To Reproduce

  1. Create new npm project.
  2. Create workspace package @repo/create in packages/create
  3. Install it in the root package
  4. npm init @repo -w package/foo

Environment

  • npm: 10.8.2
  • Node.js: v22.5.1
  • OS Name: Darwin
  • System Model Name:
  • npm config:
; "builtin" config from /opt/homebrew/lib/node_modules/npm/npmrc

prefix = "/opt/homebrew"

; "project" config from /Users/apratti/workspace/repo/.npmrc

email = (protected)

; node bin location = /opt/homebrew/Cellar/node/22.5.1/bin/node
; node version = v22.5.1
; npm local prefix = /Users/apratti/workspace/repo
; npm version = 10.8.2
; cwd = /Users/apratti/workspace/repo
; HOME = /Users/apratti
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

Labels

Needs Triageneeds review for next stepsPriority 2secondary priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions