Description
As mentioned in oven-sh/bun#2336 (comment),
Attempting to create a patch using bunx patch-package fails. The patch-package outputs the following error:
**ERROR** No package-lock.json, npm-shrinkwrap.json, or yarn.lock file. You must use either npm@>=5, yarn, or npm-shrinkwrap to manage this project's dependencies.
However, if you have pre-existing patches in the ./patches directory, you can successfully apply them using the
bunx patch-package command (or via package.json -> scripts -> "postinstall": "patch-package")As a temporary workaround to generate a patches/package+name+version.patch file
Run npm install to generate a package-lock.json file (temporarily, we'll remove it later)
Make the necessary modifications inside node-modules/
Execute npx patch-package to create the patches/package+name+version.patch file
Run rm package-lock.json && bun install
Bun has just released their 1.0 version, and its popularity seems to be growing rapidly. Will there ever be support for Bun?
Activity
OnurGvnc commentedon Sep 9, 2023
After a quick look, I see the getPackageResolution() function needs to handle
bun.lockb
.The bun.lockb file is a binary file, and I did some research on how to read it.
I looked into how the bun-vscode extension handles displaying the content of
bun.lockb
. You can see their approach here:https://github.com/oven-sh/bun/blob/ffe4f561a3af53b9f5a41c182de55d7199b5d692/packages/bun-vscode/src/features/lockfile.ts#L39
When running the command
bun ./bun.lockb
, it outputs the binary file's content as a string.I think the output looks like yarn v1, but I'm not sure.
Strengthless commentedon Sep 10, 2023
I believe so. It says yarn lockfile v1 in the output header.
pnpm patch
/patch-package
oven-sh/bun#2336baphony commentedon Apr 12, 2024
Still doesn't work with Bun 1.1.3
nobkd commentedon Apr 12, 2024
@baphony
You can run
bun install --yarn
or addto your
bunfig.toml
to avoid this issue.This adds a
yarn.lock
additionally to yourbun.lockb
on install.This is just a workaround, but prevents this issue from happening.
Reference: oven-sh/bun#2336 (comment)
baphony commentedon Apr 12, 2024
Thank you for your help @nobkd
That didn't work, but removing the yarn.lock generated by yarn did work :)
install native deps from Paranovel v1
nathanchere commentedon Jan 28, 2025
FYI As of bun 1.2, the default lock file format has switched from binary to text-based.
abumalick commentedon Jan 29, 2025
Bun has itβs own patching mechanism now
https://bun.sh/docs/install/patch
jasons42 commentedon Jan 29, 2025
My experience with bun's patching mechanism is that it is so buggy as to be unusable currently. There are many open issues with it. I would definitely still be interested in seeing support from the patch-package side.
wottpal commentedon Mar 8, 2025
Same experience as @jasons42!
evelant commentedon May 5, 2025
Here's my branch with support for bun's newer text lockfile. I committed the built
dist
so it can be installed direct from github like"patch-package": "github:evelant/patch-package",
. I'll clean it up and submit a PR when I can find time but this works for me for now https://github.com/evelant/patch-package/