Andrew Young
Andrew Young

Reputation: 1779

How do you define an npm dependency nested in a git repo?

If I have an npm dependency that is nested in a git repo, how would I define that dependency in the package.json file?

Say the git repo is at git://github.com/user/myrepo.git on the dev branch, at the relative path ./mylib from the git repo's root.

Is this possible?

Update: found this which is very close to what I want. Now, I just need to know how to specify the path within the repo+branch.

Upvotes: 3

Views: 1371

Answers (2)

Pat
Pat

Reputation: 5911

It is now pretty easy:

{
    "dependencies": {
        "sendwithus": "git+https://[email protected]/<repoowner>/<reponame>.git#<branch_name_or_commit-sha>"
    }
}

Upvotes: 0

thejh
thejh

Reputation: 45568

I don't think it's possible. However, you could specify the repo as a dependency. Then add mylib to bundledDependencies in package.json and put a shim into node_modules/mylib/index.js:

module.exports = require('myrepo')

And yes, you don't need .. or so, nodes magic does that for you.

Upvotes: 1

Related Questions