Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm git protocol dependencies

Tags:

git

npm

At work we are behind an HTTP Proxy and the git protocol (port 9418) is denied. My project has NPM dependencies and some of these dependencies have dependencies that use the git protocol, for instance:

In my package.json

"dependencies": {
    "jsdoc3" : "git+https://github.com/jsdoc3/jsdoc.git"
}

and the package.json of jsdoc3:

"dependencies": {
    "crypto-browserify": "git://github.com/dominictarr/crypto-browserify.git#95c5d505",
    "github-flavored-markdown": "git://github.com/hegemonic/github-flavored-markdown.git"
}

How can I get those dependencies, how to tell NPM to use git+https:// protocol instead of git:// protocol or to be able to use the git protocol?

To simplify things I'm on windows (it would be easier on Linux to create an SSH tunnel), and I use GIT-Bash.

Thanks

like image 809
krampstudio Avatar asked Feb 18 '13 13:02

krampstudio


People also ask

Can we install git using npm?

npm install git doesn't install git (i.e. the command line tool to manipulate git repositories). It installs the npm package called git which seems to be a JavaScript library to interact with git repositories (which makes the name accurate, but still misleading). npm is not a general-purpose package manager.

What is npm in git?

NPM is a node package management tool used to download or publish node packages via the npm package registry. It comes bundled with node. js setup. npmjs offers numerous open-source packages, such as Lodash, React, and Chalk to accelerate the development process.


2 Answers

You can tell git to use https instead of git:// with the following command:

git config --global url."https://".insteadOf git://
like image 92
Nowres Rafed Avatar answered Sep 19 '22 18:09

Nowres Rafed


Finally I found a dirty solution, but that works fine. I've modified the code of NPM to replace the git protocol by the http protocol (thanks to opened source)

On npm v1.1.69, into the file npm/lib/cache.js, I've added the following lines to the function addRemoteGit

 // ssh paths that are scp-style urls don't need the ssh://
 if (parsed.pathname.match(/^\/?:/)) {
   u = u.replace(/^ssh:\/\//, "")
 }

 //begin trick
 if(/^git:/.test(u)){
     u = u.replace(/^git/, 'https');
 }
 //end trick

 log.verbose("addRemoteGit", [u, co])
like image 29
krampstudio Avatar answered Sep 21 '22 18:09

krampstudio