Skip to content

Instantly share code, notes, and snippets.

@snuggs
Created December 26, 2024 16:46
Show Gist options
  • Save snuggs/b208d68416d180ba7c7120eee808fe0f to your computer and use it in GitHub Desktop.
Save snuggs/b208d68416d180ba7c7120eee808fe0f to your computer and use it in GitHub Desktop.
NPM Install Loop _(For Slow Connections)_
#!/bin/env bash
set -e
# https://stackoverflow.com/a/74413191
while true; do
declare tail=$( ls ${HOME}/.npm/_logs/ | tail -n 1 )
declare log="${HOME}/.npm/_logs/${tail}"
echo "log: $log"
for path in $( cat "$log" | grep 'ENOTEMPTY' | grep -oE "[^']+node_modules[^']+" ); do
echo "removing $path"
rm -rf "$path"
done # for
npm install && break
done # while
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment