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 install writes package-lock.json even after failing to find package.json #6986

Closed
2 tasks done
haines opened this issue Nov 13, 2023 · 1 comment · May be fixed by #7097
Closed
2 tasks done

[BUG] npm install writes package-lock.json even after failing to find package.json #6986

haines opened this issue Nov 13, 2023 · 1 comment · May be fixed by #7097
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 10.x

Comments

@haines
Copy link

haines commented Nov 13, 2023

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

If I run npm install and it can't find package.json, it writes an empty package-lock.json.

This is annoying because if I accidentally run it in the wrong directory, I have to clean up the lockfile afterwards.

Expected Behavior

If npm install can't find a package.json, it shouldn't write a package-lock.json.

Steps To Reproduce

  1. Switch to an empty directory, e.g. by running cd $(mktemp -d)
  2. Run npm install
  3. Observe the empty lockfile, e.g. by running cat package-lock.json

Environment

  • npm: 10.2.3
  • Node.js: 20.9.0
  • OS Name: macOS Sonoma 14.1
  • System Model Name: MacBook Pro
@milaninfy
Copy link
Contributor

Closing this as duplicate if not similer of #7892.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 10.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants