Open alexghr opened 3 years ago
it seems extremely likely this happened when merging the git conflicts.
the reason it works with a warm cache is because given the presence of the integrity field, we can retrieve content based on that data alone. with an empty cache, however, we fetch the tarball we're instructed to fetch (the resolved
field) and then compare its hash to the provided integrity. this fails, for obvious reasons.
fixing this, however, would mean that we need to revalidate the tarball url for every package before we attempt to fetch it, which would incur a significant performance cost if we did for every install. it's also only relevant for situations like this where the resolved
field was somehow modified outside of npm.
one approach i can think of to address this would be to add a phase to npm doctor
that does this validation of your package-lock.json
for you. that way we don't take the performance hit at install time for everyone, but for folks who do encounter a similar problem they would at least have some means of repairing it. i'm going to leave this issue open for now to track that need.
Is there an existing issue for this?
Current Behavior
npm resolved a dependency to the wrong archive on the registry. Snippet from my
package-lock.json
Notice that the version is
7.15.0
but theresolved
field points attypes-7.14.9.tgz
. The integrity check matches7.15.0
's shasum. I'm not sure how this happened, but on this particular branch I did end up having to resolve conflicts automatically usingnpm install
.I've been debugging this for a couple of hours because this build only failed to install while creating a Docker image (so basically installing from a clean slate), while it worked fine locally, where I had a full npm cache. Locally I could successfully install both with
npm install
andnpm ci
. Forcefully clearing the cache (withnpm cache clear --force
) recreated the issue locally as well.Expected Behavior
npm should resolve packages to the right archive for the specified package version.
Steps To Reproduce
Not sure how this happened. I suspect it was caused by solving git conflicts with
npm install
.Environment