简体   繁体   中英

npm install forked git with submodule

I'm trying to get npm to install node-gitteh as a dependency via npm install which reads from package.json . Unfortunately this npm package is broken in node 0.6.x, but no problem as there's a forked repo that fixes the issues (https://github.com/hughsk/node-gitteh.git).

Now the issue is that this forked repo has a submodule, so if I try to download the tar from github in the package.json :

, "dependencies" : {
    "gitteh" : "https://github.com/hughsk/node-gitteh/tarball/master"
}

I get an error that equates to "submodule folder not found". If I clone the same repo manually and do a recursive submodule update and an npm install from the node-gitteh folder, it works fine, but I can't figure out how to get npm to do this.

I've had the same problem and so far have just relied on cloning my module into node_modules and doing a submodule update manually. It would be nice to have npm handle this automatically.

In package.json there's a scripts field (see npm docs ) So could do

"scripts":{"preinstall": "git submodule update -i -r"}

See https://github.com/isaacs/octave-test for an example of this.

According to the docs , you need to supply the git url in a special format. Also, it needs to point to git repo (same address you would use for git clone ), not the tarball provided by github.

In your case (git over https), it would be:

, "dependencies" : {
  "gitteh" : "git+https://github.com/hughsk/node-gitteh"
}

Using this, npm will default to the master branch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM