-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
package-lock file changing based on local repository name #2264
package-lock file changing based on local repository name #2264
Comments
I think this is in some ways similar to this issue here: #1767 The difference is the package.json does contain a name field, and when the repo name matches that name field the field is not being generated inside the package-lock.json. This means if you change the directory name the field will get generated, it seems it should be generated at all times. |
i'm not able to reproduce this. do you have an example repo where you see this behavior? i tried cloning the same repo twice, removing the package-lock.json from both, and running |
Hi thanks for looking into this, ill try and create a dummy repo to reproduce it. |
@nlf Here is a repo to reproduce it: /~https://github.com/NickScottKortical/testpackagelock commands i ran to see the issue were:
/~https://github.com/NickScottKortical/testpackagelock/compare/package_lock_changed Shows the change that happens if the directory name doesn't match the name of the package, when the directory does match that name key isn't added at all and is what you see in the |
confirmed! that reproduced it for me, thank you for taking the time! |
No problem, glad i could help :) |
Caused by me having a different name (FEV2r instead of fev2r) for my git directory and this bug: npm/cli#2264
This is still reproducible and super annoying. I don't really think I understand the full picture of doing this since it seems ok to just always set |
I've also run into this issue. I renamed the project directory to save myself two keystrokes: |
I can confirm this issue on NPM version 7.19.1. When the directory name the of the package is not the same as the name of the package the package lock will be modified to add the name of the package, otherwise the line is removed. This is highly annoying as team members keep committing the package lock, even though nothing really changed. |
@nlf Any chance this could be fixed anytime soon? This is the number 1 issue that my team members are running into because some have a directory that is named the same as the package and some do not. This results in constant changes on the lockfile when committing. |
it will be fixed in the next release, which should be getting published later today |
@nlf That is great, thanks a bunch! |
@jonkoops any updates? thx |
@StefanosGiannakis this has been fixed and released as mentioned before in this thread. |
I still see this with npm 8.5.0 which was released in Feb 2022 (the same repro from #2264 (comment) of Dec 4 2020 above still reproduces it) — is the version with a fix newer than that? |
Same here with 8.18.0 |
same here |
|
this is still a problem |
8.19.2 and issue still here. Is it possible to reopen it ? |
maybe a solution for others running into this, I changed my script from npm install --include=dev && npm run dev to npm ci --include=dev && npm run dev to avoid this behavior. |
I'm running into this issue in a docker environment via ddev. package-lock.json keeps updating to the top-level folder name in the docker environment
|
As proposed before: Add a |
Can this be re-opened and fixed please?
|
Prevents package lock to use directory name. See npm/cli#2264
Prevents package lock to use directory name. See npm/cli#2264
Prevents package lock to use directory name. See npm/cli#2264
Still happening. |
I suggest npm do the following:
This will ensure matching lockfiles, regardless of the name of the parent directory. |
…missing (#21159) Closes #20859. While this is a simple fix and addresses the linked issue, there is an interesting edge case to discuss: Internal packages do not necessarily have a name field in `package.json` (see wireapp/wire-desktop#1692, facebook/react#13107 for examples). The JavaScript backend in Pants does require that each package.json define a name, but I'm not so sure that's necessarily the right behavior. It's worth considering whether we should make names optional in Pants, given that larger JavaScript monorepos may have internal packages that are not meant to be published. Furthermore, different JS package managers handle this situation differently - * [Bun doesn't handle package.json files without a name](oven-sh/bun#6317) * [npm assigns the parent directory name as the name](npm/cli#2264)
Note that if, like me, you found yourself here due to an unexpected name field being committed, it may have been due to |
Current Behavior:
package-lock.json changes depending on name of local copy of git repo, e.g. if i have two copies of the same repo locally one which matches the name in package.json and one which doesn't i get two different package-lock files, one specifies the name of the package in the inner packages list and one doesn't.
Expected Behavior:
package-lock.json should be independent of top level directory name, when working in a team there shouldn't be unnecessary changes to package-lock file due to a team member having a different local name of their git repository.
Steps To Reproduce:
npm install
Environment:
The text was updated successfully, but these errors were encountered: