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
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.
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.
You can tell git to use https instead of git:// with the following command:
git config --global url."https://".insteadOf git://
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])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With