ds300 / patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨
MIT License
10.47k stars 295 forks source link

Patching Git modules without version #497

Open tim-elmer opened 1 year ago

tim-elmer commented 1 year ago

I'm attempting to patch a package distributed via Git (Antora's default UI) that doesn't have a version number in its package.json. Not terribly surprisingly, patch-package isn't thrilled about this:

...\node_modules\patch-package\dist\makePatch.js:395
        throw e;
        ^

TypeError: Cannot read properties of undefined (reading 'replace')
    at Object.getPackageVersion (...\node_modules\patch-package\dist\getPackageVersion.js:6:51)
    at Object.makePatch (...\node_modules\patch-package\dist\makePatch.js:111:52)
    at ...\node_modules\patch-package\dist\index.js:72:25
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (...\node_modules\patch-package\dist\index.js:71:22)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)

Node.js v18.18.0

I've attempted explicitly installing the package by commit ID to no avail. Am I missing something, or is this currently not supported?

If not, I'd like to request that support be added. I'd expect patch-package to patch against the current "version" (in this case, the provided or default Git branch) if no version information is available.

tim-elmer commented 1 year ago

It may be worth noting that this issue should eventually be addressed for my particular usecase by https://gitlab.com/antora/antora-ui-default/-/issues/211, but I'd still expect patch-package to handle missing version info more gracefully.

sesm commented 1 year ago

@tim-elmer one way to fix it would be to make a patch for patch-package itself, like this: https://github.com/ds300/patch-package/issues/203#issuecomment-616187572

tim-elmer commented 12 months ago

@tim-elmer one way to fix it would be to make a patch for patch-package itself, like this: #203 (comment)

While I certainly appreciate that flexibility, I unfortunately don't understand what's going on within patch-package well enough to fix this myself. I did some digging when I initially realized what was going on, but wasn't able to coax it into ignoring the lack of a version.