The problem with using Sinopia as a full npm mirror is that it will not automatically download packages. You must manually install npm packages with npm install pkgname. I got a list of all the packages in npm from http://skimdb.npmjs.com/registry/_all_docs and then parsed the file to get only package names. I then wrote the following script to download packages from npm (which will then be stored in Sinopia):
This file contains 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
# npm-downloader.sh | |
# Jun Go gojun077@gmail.com | |
# Last Updated: 2016-10-24 | |
# This script downloads a list of all nodejs packages from npm, | |
# parses the list so that just package names remain, and then | |
# invokes 'npm install <pkg name>' in local installation mode | |
# This script is intended to be run together with a working | |
# instance of Sinopia npm cache. To make npm use Sinopia, | |
# | |
# npm set registry "http://localhost:4873/" | |
# | |
# which will update ~/.npmrc which contains npm settings for | |
# the local user. | |
TEMP="npm-pkg-list.parsed" | |
wget http://skimdb.npmjs.com/registry/_all_docs \ | |
| grep \"id\": | cut -d\" -f4 > $TEMP | |
# npm local install to cwd | |
while read -r p; do | |
printf "%s\n" "#### Installing npm package $p ####" | |
npm install "$p" | |
done<$TEMP | |
# Cleanup | |
echo "### Cleaning Up Temp Files ###" | |
if [ -f "$TEMP" ]; then | |
rm "$TEMP" | |
else | |
echo "$TEMP does not exist" | |
fi |
As of October 2016 when I mirrored PyPI using Bandersnatch, downloading 380GB took about 1.5 days on a 500 Mbit/s connection. Mirroring Ubuntu 14.04 and 16.04 repos requires 300GB each and takes almost one day for each. But using my bash script, I am only getting speeds of about 100MB per hour. Considering that npm is currently 1.2 TB in size, it would take me over 1200 days to create a complete npm mirror at the current download speed. Why is npm so slow compared to Ubuntu repos and PyPI?