-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 v7 does not preserve indentation style #1662
Comments
oof, this is a critical showstopper regression :-/ |
I've seen this reproduce locally |
Yep, that's a bug. |
- Load root project `package.json` when running loadVirtual. Fix: #1690 Fix: #1693 - Fetch metadata from registry when loading tree from outdated package-lock.json file. This avoids a situation where a lockfile or shrinkwrap from npm v5 would result in deleting dependencies on install. - Preserve `package.json` and `package-lock.json` formatting in all places where these files are written. Fix: #1662
The indentation style of the existing files is now preserved, but a newly created |
package-lock.json files should follow the same indentation used on package.json files. This commit fixes the issue by forwarding the proper indent selected for package.json to Shrinkwarp.save method. Also, added tests asserting appropriate tab-indentation for both files. Fixes: npm/cli#1662
hi @valtlai thanks for reporting these issues 😄 the
Let us know if you find more issues 😊 Thanks again! |
I am using npm@7.18.1 and able to reproduce this issue. For example: 9oelM/youtube-lite@7104320. This is actually a commit made by Renovate bot, and it uses npm 7. You can see that package-lock.json has the same number of lines added and deleted.. which just means that it does not preserve indentation. If you are in doubt of the version Renovate uses, there are also other commits that I made; for example: 9oelM/youtube-lite@f3d1460 |
@ruyadorno This issue seems to have popped back up (I'm using 7.24.2) |
... and reverting to 7.24.1 fixes that problem |
(I've also tried 8.1.1 without success) |
@gjoseph In npm v8, it will format I'm not saying that's the right thing to do, and I somewhat agree that, in lieu of an explicit format option, is should preserve whatever is there. But that's what's happening now. If you want your package-lock.json to be indented a particular way, then you have to have your package.json indented in the same fashion, and it will keep them in sync. If you'd like it to do a different thing, please open a new issue. The OP here is fixed, and what you're proposing (while imo reasonable) is a new change from that design. |
Well, I don't know what I was doing differently the other day, because I'm not able to reproduce now -- this may have been related to Lerna, which I had (probably wrongly) assumed was only causing different lock issues in the sub-packages lock files (i.e after reverting to 7.24.1, only the issues in sub-packages remained, so I assumed npm itself was causing the issues I saw in the root look file) I've now gotten rid of Lerna altogether and don't see this issue again. |
I am experiencing this bug with 8.1.0. Normally our @isaacs FYI |
Current Behavior:
The indentation style in
package.json
andpackage-lock.json
is not preserved.Expected Behavior:
For example, if
package.json
is indented using tabs, the tabs should be preserved andpackage-lock.json
should use tabs too. Similarly, the number of the spaces used for indentation should be preserved.This is the behavior in npm v6.
Steps To Reproduce:
package.json
with tab indentation:npm install globals
Environment:
The text was updated successfully, but these errors were encountered: