Skip to content

Instantly share code, notes, and snippets.

@gojun077
Created October 29, 2016 00:46
Show Gist options
  • Save gojun077/3c1c875f4e253158f1280e18db52a4eb to your computer and use it in GitHub Desktop.
Save gojun077/3c1c875f4e253158f1280e18db52a4eb to your computer and use it in GitHub Desktop.
Bash script for installing npm packages specified in file
# npm-downloader.sh
# Jun Go [email protected]
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment