0

I fixed a couple of issues in nested dependencies of my node.js project (dependencies are managed by npm). These fixes are pending pull requests and thus aren't published. What's the best way to use them in my project?

I know that I can do npm link inside the fixed version of the library and then npm link library-name inside my project to force npm to use my fixed version. This approach works but installs my library-name globally on my machine which I don't like.

Is it possible to have it locally in main project's repo, force the project to use it and don't do npm link.

Ivan Nikitin
  • 3,578
  • 27
  • 39

1 Answers1

1

You can use a url as the dependency and point it to your own repo (fork).

https://docs.npmjs.com/files/package.json#urls-as-dependencies

for example:

"dependencies": {
  "foo": "git+ssh://user@hostname:project.git#commit-ish"
}

If your pull requests are on GitHub its even easier...

As of version 1.1.65, you can refer to GitHub urls as just "foo": "user/foo-project". Just as with git URLs, a commit-ish suffix can be included.

https://docs.npmjs.com/files/package.json#github-urls

Robbie
  • 18,750
  • 4
  • 41
  • 45
  • Thanks a lot. Worked perfectly. – Ivan Nikitin Jul 14 '16 at 18:35
  • I try not to keep these around too long. If/when your PR is accepted, switch back to a version. Especially if you have an automated deployment system - otherwise if GitHub is down, you might start seeing your builds go red, and you won't be able to deploy. – Robbie Jul 14 '16 at 18:40