Open davidhousedev opened 3 years ago
Ah! Never mind. It looks like the canary build is no longer necessary as it's been merged into 4.0.0 of the package I'm using. I should be able to use this package without an issue now, so no rush on my end. But I'll leave this open in case this use case is applicable to others.
For any time-travellers :D
I think whats happening is that it checks the package.json
not the package-lock.json
(or yarn.lock
?) for the dependancies. So if its a nested dependancies you need to install the module directly into your package.json
So my package was foo
but it had a patch in @foo/variant-react-native
(which also had node_modules/foo
and node_modules/@foo
.
So I just did a npm install --save-dev @foo/variant-react-native
OFC I didn't want to install everything so I just targeted the directory. Sadly this overwrites your changes so be sure to keep the file open in your IDE and undo the change or don't update the file when you focus on your IDE again.
Tagging @ds300 -> patch-package should do some sniffing the lock file? Or note in the readme they may need to directly install the package or JSON surgery their package.json?
Actually, I think there may be an issue when installing with yarn tags.
I installed a package @aws-amplify/auth@unstable
.
When it is written to the yarn.lock
file, yarn (v1.22.5) is adding a git hash to the end of the version. So, my package.json
is reads:
"@aws-amplify/auth": "^3.4.18-unstable.10",
whereas my yarn.lock
reads:
"@aws-amplify/auth@3.4.18-unstable.10+74dc3b12f"
Not sure if this is an across the board scenario, but in my case, I had to change the comparison in getPackageResolution to be:
k.startsWith(packageDetails.name + "@") &&
installedVersion.startsWith(v.version),
...in other news, it appears that it isn't picking up my changes. I made them in a lib-esm
directory inside of the package.
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:
"mdx-prism": "https://github.com/doamatto/mdx-prism/archive/v0.3.2.tar.gz",
That package has an entry in yarn.lock like this:
"mdx-prism@https://github.com/doamatto/mdx-prism/archive/v0.3.2.tar.gz":
version "0.3.1"
resolved "https://github.com/doamatto/mdx-prism/archive/v0.3.2.tar.gz#cd4d6240dbd67031f3f8c56304d3dd034e447f25"
dependencies:
...
Note the version "0.3.1"
there - the project's package.json file says the version is 0.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 sure
Anyway, running yarn run patch-package mdx-prism
gives me the same error message as in the OP. I manually changed the version
in yarn.lock to "0.3.1+fork.0.1.0"
and the error went away, yay! It successfully generates a patch file called mdx-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:
Warning: patch-package detected a patch file version mismatch
Don't worry! This is probably fine. The patch was still applied
successfully. Here's the deets:
Patch file created for
mdx-prism@0.3.1+fork.0.1.0
applied to
mdx-prism@0.3.1
At path...
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
same problem with patch package when i want to patch changes to react-native-google-places-autocomplete
try remove node_modules, then npm install
Thanks 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.It also fails if I try to supply the explicit version as it is shown in the lock file:
package.json
yarn.lock