Search code examples
node.jsnpmnpm-installnpm-shrinkwrap

Shipping node.js project with custom dependencies


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.


Solution

  • 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