nofi

If you're online, it installs/caches npm packages with --force (so you get fresh packages). If you're offline, it installs cached packages with --cache-min.

Usage no npm install needed!

<script type="module">
  import nofi from 'https://cdn.skypack.dev/nofi';
</script>

README

nofi

npm Online-First Installer

Do you switch between online/offline environments somewhat regularly?

Installation/Usage

  • npm i -g nofi
  • Replace all your npm install commands with nofi

Examples

✖︎  npm install
✔︎  nofi
✖︎  npm install --save foo
✔︎  nofi --save foo
✖︎  npm install --save-dev foo
✔︎  nofi --save-dev foo
✖︎  npm install --save-optional foo
✔︎  nofi --save-optional foo

Flag aliases and installing multiple packages work as well...

  • nofi -S foo
  • nofi -D foo bar
  • nofi -O foo bar baz

How does it work?

  1. Test internet connection using is-online.
  2. If online, use npm install --force to install/cache the latest package.
  3. If offline, use npm install --cache-min Infinity to install from your cache (usually located in ~/.npm).