Rheinard Korf logo
Rheinard Korf
  • Posts
  • Notes
  • Archived

Keeping a local cache of NPM packages.

I often work with NPM packages that have many dependencies. Usually I’m ok with letting npm just do its thing, but when recently introduced to Playwright the idea of having to download all the headless browsers for experimentation seems tedious. Thankfully! I remembered about a package called local-npm, which sets up an npm proxy server. It also works offline!

Install local-npm

npm install -g local-npm

Run the server

# Inside directory where you want to cache the files.

Point npm at the local proxy

npm set registry

If you ever need to switch back run this command:

npm set registry https://registry.npmjs.org

BONUS: If you are on a Mac check out local-npm-launch-agent to automate some of this.

© 2020 Rheinard Korf MixerTwitterGitHub