Comments (25)
pnpm has a pnpm patch
command since v7.4
from patch-package.
For anyone else late to the party, @milahu did the work and you can continue with patch-package and PNPM like nothing has changed by doing:
pnpm remove patch-package
pnpm install @milahu/patch-package-with-pnpm-support
The same commands apply (the executable is still node_modules/.bin/patch-package
)
from patch-package.
...err worked, pre **ERROR** No package-lock.json, npm-shrinkwrap.json, or yarn.lock file.
message 😆
from patch-package.
same here, pnpx patch-package <pkg>
not working
patch-package 6.2.2
**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.
from patch-package.
from patch-package.
This worked for me. Thanks @milahu !
npx @milahu/patch-package-with-pnpm-support @my-org/my-package
Edit, I don't think that --reverse
is working @milahu:
npx @milahu/patch-package-with-pnpm-support @my-org/my-package --reverse
from patch-package.
@vjpr with a pnpm hook you can install a package from a local tarball instead of the registry. The local tarball can contain the modified package. Or you could publish the fixed package with a different name, or you could install if from your fork.
from patch-package.
This still doesn't seem to work for me after removing and installing the @milahu package:
$ node_modules/.bin/patch-package react-async-hook
patch-package 6.4.9
**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.
from patch-package.
It seems to apply existing patches ok using [email protected]
, [email protected]
and [email protected]
- not sure about generating them, but that can be done manually if necessary.
from patch-package.
I ended up writing a garbage little script to generate patches from my pnpm project's node_modules, but using npm
and a temporary workspace to actually generate the patches.
https://gist.github.com/cdaringe/66c7cd5f95f74766f9eb1e699fdd7399
it's rough around the edges, but gets the job done. YMMV
from patch-package.
The solutions above aren't compatible with pnpm's
.pnpm
directory.
only works for top-level dependencies, as pnpm has deep node_modules
→ add the dependency to package.json
from patch-package.
Hi! Looks like patch-package wouldn't work with pnpm, unfortunately.
pnpm uses hard links and symlinks to save one version of a module only ever once on a disk. When using npm or Yarn for example, if you have 100 projects using the same version of lodash, you will have 100 copies of lodash on disk. With pnpm, lodash will be saved in a single place on the disk and a hard link will put it into the node_modules where it should be installed.
Meanwhile, patch-package requires files to be fully copied in to node_modules, not just linked.
from patch-package.
Hmm, I did not think of that.
@zkochan How could this package be used for pnpm? Can a hook patch a module?
from patch-package.
Thanks @zkochan
The other issue is that patch-package's core patch generation UX flow wouldn't work. That flow is:
- Edit files inside your node_modules folder
- run patch-package to generate a patch file based on your edits
With pnpm, editing files inside your node_modules folder will affect all other pnpm projects on your machine, which is probably not what you want.
The patch application process could be automated using the hooks, but I can't think of a way to make patch generation easy. Any ideas?
from patch-package.
With pnpm, editing files inside your node_modules folder will affect all other pnpm projects on your machine, which is probably not what you want.
For patch creation, I think this workflow still works. When pnpm install
is run, it detects that the global store has changed and will reinstall so there is no problem there. I do it all the time.
For patch application, though currently it would never work. It would need to use the pnpm plugin feature as @zkochan mentioned.
from patch-package.
closing this issue due to inactivity
from patch-package.
I'm hitting this today. Use pnpm
regularly and now have a pressing need to patch a dependency. Unfortunately creating a patch fails under pnpm
with:
$ npx patch-package mname -INSERT-
patch-package 6.2.0
• Creating temporary folder
• Installing [email protected] with npm
• Diffing your files with clean files
{ Error: ENOENT: no such file or directory, scandir '/tmp/tmp-4739623rx72YYljFtx/node_modules/mname'
at Object.readdirSync (fs.js:790:3)
<snip>
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: '/tmp/tmp-4739623rx72YYljFtx/node_modules/mname' }
<snip>
Error: ENOENT: no such file or directory, scandir '/tmp/tmp-4739623rx72YYljFtx/node_modules/mname'
at Object.readdirSync (fs.js:790:3)
Digging into the way patch-package
does its diffing, I suspect copying a directory which is itself a symlink is causing the barf.
It'd be great to support pnpm
- in my case, I'm happy to have a patch to a dependency affect all the versions of that package installed on the system.
Aside/as well as pnpm
hooks, the https://pnpm.js.org/en/workspaces support might be a way of getting what we want, as it looks like packages are stored per-workspace.
from patch-package.
I am experiencing the same problem, can this be fixed on patch-package
's side or does this need to be done in pnpm
?
from patch-package.
pnpm
works, just with caveats.pnpm
users need to manage how they land packages node_modules
.
- modules in need of patch need to be top-level to be hoisted into
node_modules
. you can do this by promoting your transitive deps to 1st-class deps, right in your package.json - install method needs to be clone or copy
from patch-package.
This still doesn't seem to work for me
thanks for reporting. this could be the same issue as milahu#4
does npx patch-package --debug
say more?
what does patch-package say with
--- a/node_modules/@milahu/patch-package-with-pnpm-support/dist/detectPackageManager.js
+++ b/node_modules/@milahu/patch-package-with-pnpm-support/dist/detectPackageManager.js
@@ -54,6 +54,13 @@
const packageLockExists = fs_extra_1.default.existsSync(path_1.join(appRootPath, "package-lock.json"));
const shrinkWrapExists = fs_extra_1.default.existsSync(path_1.join(appRootPath, "npm-shrinkwrap.json"));
const yarnLockExists = fs_extra_1.default.existsSync(path_1.join(appRootPath, "yarn.lock"));
+console.dir({
+ packageLockExists,
+ shrinkWrapExists,
+ yarnLockExists,
+ findYarnWorkspaceRoot: find_yarn_workspace_root_1.default(),
+ isFileInPnpmRoot: isFileInPnpmRoot(appRootPath, "pnpm-lock.yaml"),
+});
if ((packageLockExists || shrinkWrapExists) && yarnLockExists) {
if (overridePackageManager) {
return overridePackageManager;
from patch-package.
@boldwade please try milahu@3545f96
do you have a lockfile in a parent folder? (or in the same folder as package.json)
from patch-package.
Hi, I couldn't find any solution to patch pnpm packages. The solutions above aren't compatible with pnpm's .pnpm
directory.
from patch-package.
@milahu thanks. What's missing to integrate your changes into the official repo?
from patch-package.
integrate your changes into the official repo?
the owner is gone, so nobody has access*. feel free to maintain a fork ; )
* github requires the owner's consent for project transfer, which is good
For account security reasons, we’re unable to alter repository ownership. This policy is in place to protect all account owners from unauthorized takeovers. (source)
from patch-package.
from patch-package.
Related Issues (20)
- Patching Git modules without version HOT 3
- Warn when patch exists for old version of package HOT 5
- [Proposal] Reduce `patch-package` installation size HOT 2
- [Discussion] Global patches HOT 1
- New patch parse failed
- Add new dependency to a package
- Does patch-package support node12? HOT 1
- Failed to apply patch for package react-native-agora HOT 1
- Is there a way to convert pnpm patches to patch-package patches? Or do they use the same format? HOT 2
- -
- Uniterpretable Error during makePatch HOT 3
- react-native-otp-verify+1.1.6.patch
- Confusing syntax error message when pointing to a package that does not exist
- Patch not applied after package upgrade
- inflight - Missing Release of Resource after Effective Lifetime HOT 1
- how get the post-install to run when installing cosmos (or storybook and the like)
- Patch cannot be applied when it simultaneously renames and modifies the file HOT 1
- npx patch-package [email protected] error
- Not sure if I'm clear on how to re-apply updated patch...
- Can patch-package detect content changes in package.json? Let's say I changed a dependency version? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from patch-package.