Fails to create patch file for complex package version
See original GitHub issueThanks for your work on this! I really hope we can start using it in our project. We are currently using a canary build of a package, gatsby-source-contentful
and installing it using a non-standard version. However, when I try to create a patch, there is a failure finding associated data in the lock file.
$ yarn patch-package gatsby-source-contentful
yarn run v1.22.5
$ /Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/.bin/patch-package gatsby-source-contentful
patch-package 6.2.2
• Creating temporary folder
Error: Can't find lockfile entry for gatsby-source-contentful
at Object.getPackageResolution (/Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/getPackageResolution.js:41:19)
at Object.makePatch (/Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/makePatch.js:49:66)
at /Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/index.js:48:25
at Array.forEach (<anonymous>)
at Object.<anonymous> (/Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/index.js:47:22)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
/Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/makePatch.js:183
throw e;
^
Error: Can't find lockfile entry for gatsby-source-contentful
at Object.getPackageResolution (/Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/getPackageResolution.js:41:19)
at Object.makePatch (/Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/makePatch.js:49:66)
at /Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/index.js:48:25
at Array.forEach (<anonymous>)
at Object.<anonymous> (/Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/patch-package/dist/index.js:47:22)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
It also fails if I try to supply the explicit version as it is shown in the lock file:
$ yarn patch-package 'gatsby-source-contentful@^2.3.55-next.21'
yarn run v1.22.5
$ /Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/.bin/patch-package gatsby-source-contentful@^2.3.55-next.21
patch-package 6.2.2
No such package gatsby-source-contentful@^2.3.55-next.21
File not found: /Users/davidhouse/Code/sandbox/frontend/butcherbox-frontend/node_modules/gatsby-source-contentful@^2.3.55-next.21/package.json
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
package.json
"gatsby-source-contentful": "^2.3.55-next.21",
yarn.lock
gatsby-source-contentful@^2.3.55-next.21:
version "2.3.55-next.21"
resolved "https://registry.yarnpkg.com/gatsby-source-contentful/-/gatsby-source-contentful-2.3.55-next.21.tgz#0e8f15f87061c094efcbd1f02dc6a87389c72b54"
integrity sha512-tXWbaA7ByB5QbQs6if4LsnlN11H0F5VZn/oBFfWh1lI5Cb7U+GxfszxWZ/9Wp7U8jOAKaNdZq3BsNIXvXPCA1A==
dependencies:
"@babel/runtime" "^7.11.2"
"@contentful/rich-text-react-renderer" "^14.1.1"
"@contentful/rich-text-types" "^14.1.1"
"@hapi/joi" "^15.1.1"
axios "^0.20.0"
base64-img "^1.0.4"
bluebird "^3.7.2"
chalk "^4.1.0"
contentful "^7.14.7"
fs-extra "^9.0.1"
gatsby-core-utils "1.3.23"
gatsby-plugin-utils "0.2.33"
gatsby-source-filesystem "2.3.34"
is-online "^8.5.0"
json-stringify-safe "^5.0.1"
lodash "^4.17.20"
node-fetch "^2.6.1"
progress "^2.0.3"
qs "^6.9.4"
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Getting errors when patching a npm package - Stack Overflow
The problem here is that you're using two different tools to patch the npm package, and using a different one locally than in...
Read more >patch-package | Fix broken node modules instantly - YouTube
patch - package is a tool that has saved me a couple of times when I found a bug in an npm package...
Read more >patch-package - Bountysource
ERROR Failed to apply patch for package react-native at path ... Since NPM version 7, the package-lock.json version 2 file now uses a...
Read more >Update application dependencies, patch a managed node ...
Install operating system updates. Update the package dependencies of the application. Restart the system. Perform an application-specific health check.
Read more >Applying a patch in a feature branch - Drupal
The patch command is useful for patches that don't apply, as it will apply most of the patch and then you may be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I got this same “Can’t find lockfile entry” error in a slightly different situation. patch-package 6.2.2
I’ve installed a package directly from a github tarball - here’s what it looks like in package.json:
That package has an entry in yarn.lock like this:
Note the
version "0.3.1"
there - the project’s package.json file says the version is0.3.1+fork.0.1.0
: https://github.com/doamatto/mdx-prism/blob/22ca7f91cc3e86096d0ff5bf20cb511ad00b028c/package.json#L3 That mismatch might be a yarn bug? Not sureAnyway, running
yarn run patch-package mdx-prism
gives me the same error message as in the OP. I manually changed theversion
in yarn.lock to"0.3.1+fork.0.1.0"
and the error went away, yay! It successfully generates a patch file calledmdx-prism+0.3.1+fork.0.1.0.patch
.Unfortunately, I get a version mismatch warning when applying the patch, but it’s good enough for me since everything still works in CI:
TLDR: make sure the version in yarn.lock matches what’s in the dependency’s package.json and maybe you’ll have better luck with patching
try remove node_modules, then npm install