I need to install a module from a private github repo. In order to do that I'll run npm install git+https://[API-KEY]:x-oauth-basic@github.com/<name>/<repo>.git#<branch>
. My package.json
file would look something like this:
"dependencies: {
...
"private-repo-name": "git+https://[API-KEY]:x-oauth-basic@github.com/<name>/<repo>.git#<branch>",
...
}
In this case, "private-repo-name"
corresponds to the name
field of the package.json
of the private repo, ie:
"name": "private-repo-name"
My question is: How do I change the package name during npm install
without changing the name
field of the private repo?
Note: For public npm modules this wouldn't be a problem due to npm modules not sharing namespaces in the npm registry, but for privately developed modules that arent hosted in npm, there is a potential for the module name to conflict with current or future public npm modules in the npm registry.
it can be done by setting up system HTTP_PROXY
and HTTPS_PROXY
environment variable to your private repo. after that it will work for command like npm install
. but it will install the package with the name they have in the repo.
It turns out that you can simply run npm install new-name@git+https://[API-KEY]:x-oauth-basic@github.com/<name>/<repo>.git#<branch>
how to install multiple versions of package using npm
There's no coupling between the keys in the dependencies
field & the name
field in the private repo.
ie
"dependencies: {
...
"new-name": "git+https://[API-KEY]:x-oauth-basic@github.com/<name>/<repo>.git#<branch>",
...
}
After this, commands like npm update new-name
would work as expected.
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.