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

install-subset

v6.0.0

Published

Install a subset of npm dependencies based on given contexts

Downloads

5,547

Readme

npm version npm downloads per month License: MIT

You can exclude some npm dependencies with install-subset when you don't need them.

Consider:

  • A CI server for your builds: you may not need your linting or testing tools. With a busy or shared server, you can save precious time.
  • A data generation library you only need once.
  • Toolsets that only a certain team member needs or uses, depending on their job, IDE or preferences.
  • Developing an application out of a monorepo that only needs certain dependencies for certain environments. (e.g. Mobile, Web, Desktop, or a Docker container)

Even with npm 5 and yarn, installing node modules can be a long and painful task. Sometimes you have to build a native bindings like node-sass or couchbase, and sometimes you just have 100,000 dependencies. You are at the mercy of:

  • Your connection speed & latency.
  • Your computer's willingness to cooperate.
  • The number of dependencies.
  • The disk space available.
  • Your patience.

Installation

npm install -g install-subset

Usage

Add something like this to your package.json...

"subsets": {
  "build": {
    "include": [
      "babel-cli",
      "dotenv",
      "webpack"
    ]
  },
  "test": {
    "exclude": [
      "eslint",
      "prettier"
    ]
  },
  "container": {
    "exclude": [
      "nativescript",
      "serverless",
      "ngrok"
    ]
  }
}

Or, you can use a subset.config.js file for more flexibility:

const both = [
  'dotenv'
]

module.exports = {
  build: {
    include: [
      'babel-cli',
      'webpack',
      ...both
    ]
  },
  test: {
    exclude: [
      'eslint',
      'prettier',
      ...both
    ]
  }
}

In your terminal: $ subset install test

This installs all of your application dependencies, excluding eslint and prettier, which are listed under your devDependencies.

If you would like install-subset to consider all of the dependencies of your application when evaluating subsets...

In your terminal: $ subset install container --all

If you would like install-subset to consider multiple subsets...

In your terminal: $subset install test container

Case Study

fakeit is an amazing fake data generation library with support for couchbase, complicated related data models, multiple export options and more. However, its dependency tree is large, and has a dependency on a native Couchbase binary. In an example React Native project, just excluding this one rarely used devDependency cuts install time by around 29 seconds.

Warm cache, yarn v1.5.1, fresh install, without install-subset

  rm -rf node_modules && yarn
  ...
  real    0m40.496s
  user    0m32.451s
  sys     0m11.309s

Warm cache, yarn v1.5.1, fresh install With install-subset excluding fakeit

  rm -rf node_modules && subset install "development"
  ...
  real    0m11.157s
  user    0m9.261s
  sys     0m6.134s