5

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?

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Peter. This fix is actually already in the code base, but it hasn't been released to npm yet. Here's more on the specifics: github.com/tmpvar/jsdom/commit/… I'm going with the fix that tmpvar suggested. i.e. "npm install github.com/tmpvar/jsdom/tarball/…". However, your suggestions looks good for the information I posted in the original question.
3

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!

1 Comment

This also works great when the fix is in a fork/pullrequest but hasn't made it in to the main repo yet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.