Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
anthonyjpratti opened this issue Aug 5, 2024 · 1 comment · Fixed by #7721 or GulajavaMinistudio/cli#124
Closed
2 tasks done
Assignees
Labels
Needs Triage needs review for next steps Priority 2 secondary priority issue

Comments

@anthonyjpratti
Copy link

anthonyjpratti commented Aug 5, 2024

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.
@anthonyjpratti anthonyjpratti added Bug thing that needs fixing Needs Triage needs review for next steps labels Aug 5, 2024
@anthonyjpratti
Copy link
Author

Related to #5596

@wraithgar wraithgar reopened this Aug 9, 2024
@wraithgar wraithgar changed the title [BUG] npm init fails to run due to missing artifact in registry, whereas npx will succeed. [BUG] npm init does not use locally installed version of given package. Aug 9, 2024
@wraithgar wraithgar added Priority 2 secondary priority issue and removed Bug thing that needs fixing labels Aug 9, 2024
@milaninfy milaninfy self-assigned this Aug 13, 2024
wraithgar pushed a commit that referenced this issue Aug 13, 2024
`npm init` calls `libnpmexec` with path and runPath, for most cases it
would not matter but when we have a package installed locally on root
and we want to run `npm init that-package -w workspace` it should
identify that-package is installed and use that to init new workspace
package. here the `path` is where node_modules are and `runPath` is cwd
to run the command.
Fixes: #7700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Triage needs review for next steps Priority 2 secondary priority issue
Projects
None yet
3 participants