Skip to content

Instantly share code, notes, and snippets.

@AlexAegis
Created June 28, 2021 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexAegis/7c0e93a614e08384e770d969aa34d9e6 to your computer and use it in GitHub Desktop.
Save AlexAegis/7c0e93a614e08384e770d969aa34d9e6 to your computer and use it in GitHub Desktop.
Recursively pack all dependencies of an npm project
#!/bin/sh
# This script will run npm pack on every dependency and dependencies of a dependency
# on 8 threads. It's useful if you want to then upload everything to a private registry.
mkdir packages
cd packages || exit 1
# There is some unwanted garbage in the output of `npm ls` hence the inverted greps
npm ls --all --registry https://registry.npmjs.org 2> /dev/null |
grep -v deduped |
grep -v 'UNMET OPTIONAL DEPENDENCY' |
grep -v '__ngcc_entry_points__' |
sed 's/^.* //g' |
sort |
uniq |
xargs -P 8 npm pack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment