-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
[npm] Support lockfile version 3 #393
Comments
Sure, open to PRs on this 👍🏻 |
Can anyone explain, why this TypeError: Cannot read properties of undefined (reading 'dependencies') when trying to run npx patch-package error, is coming? I'm unable to understand it. |
The package-lock.json lockVersion 3 has different format than version 2. Specifically, "dependencies" node is not present as one of the top nodes in package-lock.json. The patch-package expect it to be there and fails when it is missing. |
And this also happens with yarn as well?
|
when I am doing yarn patch-package it's throwing the error. --use-yarn flag, while using yarn doesn't throw the error. |
I've opened a PR to solve this issue here: #434 |
modify this file directly 👉🏻 const lockfile = require(path_1.join(appPath, packageManager === "npm-shrinkwrap"
? "npm-shrinkwrap.json"
: "package-lock.json"));
if (lockfile.lockfileVersion > 2) {
return Object.entries(lockfile.packages).find(el => el[0].includes(packageDetails.name))[1].resolved;
}
const lockFileStack = [lockfile];
for (const name of packageDetails.packageNames.slice(0, -1)) {
const child = lockFileStack[0].dependencies;
if (child && name in child) {
lockFileStack.push(child[name]);
}
}
lockFileStack.reverse();
const relevantStackEntry = lockFileStack.find((entry) => entry.dependencies && packageDetails.name in entry.dependencies);
const pkg = relevantStackEntry.dependencies[packageDetails.name];
return pkg.resolved || pkg.from || pkg.version; |
This is happening to me with
|
Upgrading from
|
Since NPM version 7, the package-lock.json version 2 file now uses a
packages
field, and thedependencies
field is duplicated for backwards compatibility.It is possible to configure NPM to use a package-lock.json version 3, which omits the
dependencies
field to greatly reduce the size of the lock file. See https://docs.npmjs.com/cli/v8/using-npm/config#lockfile-version.To support
lockfile-version=3
, patch-package must be able to interpret thepackages
field of the lock file.The text was updated successfully, but these errors were encountered: