I'm using the jsdom package for node.js, but I ran into a problem with it. I fixed it my manually editing the source in /node_modules/jsdom/lib/jsdom/level2/languages on my computer, and it works. However, now I want to publish my program to another server.
What is the best way of handling this modified dependency? In general, how should I go about handling dependencies that are modified from the npm install?
Well, the right thing to do is submit a patch to the maintainer so it can be fixed upstream (long term). In the mean time just keep your modified file around and after you install the main package, rename the original file (mv file.js file.js.ORIG
) and then symlink in your copy (ln -s ../../../patches/jsdom/level2/languages/file.js file.js
).
That's a quick and dirty option. Another option would be to build a new npm tarball with your modified source and point NPM at that. The npm install
command can take a local filesystem path to a .tar.gz archive. That would work as well.
If the fix is already included in the codebase, but not released to npm yet, you can use npm to install a tarball instead of a registered package. Github provides a tarball for each commit, just click downloads.
So for this particular problem with jsdom. You can use the following npm command:
npm install https://github.com/tmpvar/jsdom/tarball/4cf155a1624b3fb54b2eec536a0c060ec1bab4ab
It also works in package.json:
"dependencies" : {
"jsdom" : "https://github.com/tmpvar/jsdom/tarball/4cf155a1624b3fb54b2eec536a0c060ec1bab4ab"
}
Read more here: https://github.com/tmpvar/jsdom/commit/4cf155a1624b3fb54b2eec536a0c060ec1bab4ab#commitcomment-475293
Thanks tmpvar!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With