npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dzenly/nmc

v0.3.11

Published

Node modules cache

Downloads

49

Readme

Node modules cache

Speeds up npm install / npm ci commands. Especially if you have multi-core CPU.

Known issue on Windows

You must have tar, supporting xpJSf options, in your OS. So everything is ok on Linux. But for Windows you must use tar from cygwin or smth like. I could use npm tar module, but it supports max 99 symbols in file name. If tar module will be fixed, I will use it.

Installation

npm install -g @dzenly/nmc

Usage

nmc <npm arguments destined for installation the whole node_modules>

Runs npm with the specified arguments (saving node_modules in cache) or unzips archieve from cache.

nmc --nmc-clean

Cleans the whole nmc cache.

nmc --nmc-cache-size

Returns size of current cache.

Examples:

  • nmc ci
  • nmc ci --production
  • nmc install

How it works

It calculates sha256 hash from:

  • os.arch()
  • os.platform()
  • os.release()
  • os.type()
  • process.versions
  • npm --version
  • npm arguments passed in the command line
  • package.json
  • package-lock.json (if exists)
  • npm-shrinkwrap.json (if exists)

If hash is found in cache - just unzips it from cache.

If hash is not found - runs npm with specified parameters and then saves node_modules to the inner directory (cache) as <hash>.txz.

Warning about postinstall.

nmc checks stdout to detect if there was postinstall run for the main module (not for dependencies), and if yes - it will run npm run postistall after unzipping of cached archive.

So if your dependencies do something outside its node_modules, nmc, probably, is not for you.

About uninstall

Please, use only npm arguments destined to installation. For other arguments the behaviour is undefined.

nmc does not support uninstall. So you can use npm install -S some-module and then run nmc install to cache you new node_modules.

About nmc install some-new-module

No, no, no. Use only commands for the whole node_modules installation for your package.json, package-lock.json and npm-shrinkwrap.json.

Use cases

  • CI builds speed up.
  • Fast branch switching for developers.

Environment variables

  • NPM_ORIG - path to npm binary, it allows to create such a script at your ~/bin/npm.
#!/usr/bin/env bash

if [ -z "$NPM_ORIG" ]; then
  export NPM_ORIG=$(dirname $(which nmc))/npm
fi

if [[ -n "$NPM_USE_NMC" ]]; then
  if [[ "$1" == "install" || "$1" == "i" || "$1" == "ci" ]];then
    echo Install by NMC $NPM_ORIG "$@"
    nmc "$@"
    exit
  fi
fi

echo Install by NPM $NPM_ORIG "$@"

$NPM_ORIG "$@"

And add it to path: export PATH=~/bin:$PATH

So nmc will be used instead of npm if NPM_USE_NMC will be defined.