Comment by arp242
2 years ago
That's just "rm -r node_modules && npm install".
Aside from needlessly taking a long time, it also means we're back to "if something goes wrong we're left with an inconsistent node_modules".
2 years ago
That's just "rm -r node_modules && npm install".
Aside from needlessly taking a long time, it also means we're back to "if something goes wrong we're left with an inconsistent node_modules".
No, it's more than that. Did you read the documentation page linked in the comment you replied to?
> But what about after the command has run?
If you munge around in node_modules after a successful `npm ci`, that's on you. If you run scripts that do, that's on you. If you depend on packages that run such scripts, that's on you.
> What, you mean I'm supposed to audit my dependencies myself? That's too much work!
Yes, as part of code review we expect our devs to manually inspect every change in the lockfile for anything that matters or might start to, which includes most things. No, you can't outsource that task to an AI, regardless of how well-performing it appears.
It says exactly that: "If a node_modules is already present, it will be automatically removed before npm ci begins its install".
I didn't "munge around" in node_modules; I said "if something goes wrong". Like I said in my previous comment: "I found this out a few ago after I had some corrupted files due to a flaky internet connection". That's not munging around, that's computers being computers. Network errors happen. Disk errors happen. Memory errors happen. Things like that. I've also had an install ISO corrupted at some point. I always check the sums since, just in case because there was a lot of confusion involved before I found out the ISO was just downloaded wrong for some reason. Stuff doesn't often get randomly corrupted, but it does happen, and with 2GB ISO files (or 2GB node_modules) the chances do grow.
On Go I can do "go mod verify". I think yarn has "yarn check" for this (but didn't verify). I don't know about other package managers off-hand, but if they don't have something for it, they should. You need to be able to verify the content on disk is identical to what's expected.
I never mentioned anything about auditing dependencies or AI.
Your entire post is a masterclass in arguing against things that were never claimed and forceful injection of your own bugbears. I just want to check if node_modules is identical to what's expected, just in case, because computers kind of suck and are unreliable.
Well, you did say (emphasis mine):
> That's just "rm -r node_modules && npm install".
And there is more to it, very much relevant to your original complaint, which is not applicable to it.
> I didn't "munge around" in node_modules; I said "if something goes wrong". Like I said in my previous comment: "I found this out a few ago after I had some corrupted files due to a flaky internet connection".
I do believe that if you had run `npm ci` instead of `npm install`, that would have resulted in an error and an empty node_modules instead of inconsistency.
> Disk errors happen. Memory errors happen. Things like that.
Those are at lower layers than the package manager. I think it's unreasonable to expect the package manager to check for inconsistencies induced by hardware errors. You have file-system level solutions (zfs,btrfs) and things like ECC for that. Nothing is a silver bullet.
> I've also had an install ISO corrupted at some point. I always check the sums since, just in case because there was a lot of confusion involved before I found out the ISO was just downloaded wrong for some reason
Good! It happens. Keep doing it. There's a reason integrity verification is a step in every Linux distro installation guide.
> Your entire post is a masterclass in arguing against things that were never claimed and forceful injection of your own bugbears.
Fair! Though I do want to call out your "Who is carefully auditing if the repo URL in the lockfile is actually the correct one?" in a sibling comment - apparently the inferred bugbear wasn't all off-base :p
> I just want to check if node_modules is identical to what's expected, just in case, because computers kind of suck and are unreliable.
I think we can agree on that npm is not sufficient tooling for this. My response is additional tooling. I guess you want a more feature-complete package manager. Wish I had one to recommend. npm is severely neglected after the MS acquisition; yarn maintainers are completely misguided on a couple of fundamentals; every time I get around to take another look at pnpm either I run into a bug or catch a recent enough breakage-outside-of-semver that I decide they're not ready yet...