Last active
December 18, 2015 13:03
-
-
Save vladimir-ivanov/3c3ef070d73301ca3ccd to your computer and use it in GitHub Desktop.
Fix Instructions for npm installing dependencies in Intranet with no access to Internet e.g. npm install npm ERR fetch failed https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to deal with dependencies which depend on dependencies referenced with github.com rather than a version | |
Works for Build Servers which do not have access to the Internet, having all npm dependencies cached in local registry e.g. nexus | |
In case you introduce a new library or upgrade one, which relies on github.com somewhere | |
Fixes | |
npm install [email protected] | |
npm ERR fetch failed https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz | |
LOCAL_NEXUS_DOMAIN = http://nexus.dev.uk.companyName/content/groups/npm-all/ | |
1. Install npm shrinkwrap on your local box - must be global e.g. npm install -g npm-shrinkwrap | |
2. Delete everything from node_modules, remove shrhinkwrap.json file (back it up) | |
3. Run npm install | |
4. Run npm shrinkwrap --dev - it will generate another npm-shrinkwrap.json file | |
5. Replace the references to github tars e.g. | |
"xmlhttprequest": { | |
"version": "1.5.0", | |
"from": "https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz", | |
"resolved": "https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz" | |
} | |
with your nexus server e.g. | |
"xmlhttprequest": { | |
"version": "1.5.0", | |
"from": "[LOCAL_NEXUS_DOMAIN]rase-xmlhttprequest/-/rase-xmlhttprequest-1.5.0.tgz", | |
"resolved": "[LOCAL_NEXUS_DOMAIN]rase-xmlhttprequest/-/rase-xmlhttprequest-1.5.0.tgz" | |
} | |
Make sure that file is in nexus against the correct version of it, else: | |
Add the library to your registry/ nexus | |
npm set registry [LOCAL_NEXUS_DOMAIN] | |
clone the project you want to publish to nexus | |
modify package.json name -> e.g. "name": "rase-xmlhttprequest" | |
npm publish --registry [LOCAL_NEXUS_DOMAIN]content/repositories/npm-internal/ | |
6. Repeat the process for each library e.g. | |
"has-cors": { | |
"version": "1.0.3", | |
"from": "[email protected]", | |
"resolved": "[LOCAL_NEXUS_DOMAIN]has-cors/-/has-cors-1.0.3.tgz", | |
"dependencies": { | |
"global": { | |
"version": "2.0.1", | |
"from": "https://github.com/component/global/archive/v2.0.1.tar.gz", | |
"resolved": "https://github.com/component/global/archive/v2.0.1.tar.gz" | |
} | |
} | |
}, | |
7. Replace the remaining https://registry.npmjs.org with your nexus instance e.g. | |
"resolved": "https://registry.npmjs.org/request/-/request-2.42.0.tgz" | |
with | |
"resolved": "[LOCAL_NEXUS_DOMAIN]request/-/request-2.42.0.tgz" | |
8.Commit/ push the resulting shrnkwrap.json file and the build server should read that when npm install is run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment