verdaccio-offline-storage

Local package cache as first class citizen.

Usage no npm install needed!

<script type="module">
  import verdaccioOfflineStorage from 'https://cdn.skypack.dev/verdaccio-offline-storage';
</script>

README

verdaccio-offline-storage

📦 local-storage plugin BUT with locally available packages as first class citizens.

tl;dr: Makes Verdaccio's package cache actually work when going offline.

This storage plugin provides only the packages versions stored in a local-storage storage. This means that if you are in an offline environment (no access to registry.npmjs.org or any other uplink) you:

  • won't get errors because of missing packages versions if you installed them before (when online). This is kind of solved thanks to the lock files generated by yarn and other package managers, but could be an issue if you don't have the lock files (like when using an old version of npm).
  • will be able to safely install modules using the @latest version, which will be the latest locally available. This is a major issue for offline environments since many packages uses in their dependencies version ranges, and the best matching version to install might not be locally available. However, the version ranges could be satisfiable with the locally available versions (actually, they are: they were when installed in an online environment).

Features

  • local-storage compatible, meaning you can use the default storage without breaking it.
  • No lockfile required to install again the same modules, meaning all the dependencies will be resolved again if they were cached in the past. If the registry worked when online, then it must work later when offline for the same dependencies requirements.
  • yarn add or npm install just works! No more errors due to missing versions.
  • Lists all the locally available packages on the web UI. Yes, all of them, not only the uploaded ones.
  • Default local-storage behavior when online (see usage section below), but resolving locally all packages with no proxy defined.

Usage

First off, install the plugin:

yarn global add verdaccio-offline-storage

# npm -g i verdaccio-offline-storage

Then edit the config.yaml with the following:

# The plugin will use the `storage` field just like the default `local-storage` plugin does
storage: /path/to/the/storage/cache/directory/

# Add this and Verdaccio will load the plugin 
store:
  offline-storage:

# Now on, every package with no `proxy` defined will be resolved locally!

# Optionally, if you want to resolve locally EVERY package (like in the v1 version of this plugin)
# just add this to the config:
offline: true

And voilá, enjoy your working offline environment.


Development

First, install all deps:

yarn

Then use the following npm tasks.

  • yarn build

    Builds the distributable archives in the /lib directory.

  • yarn lint

    Lints the code

For more information about any of these commands run npm run ${task} -- --help.