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

licensee

v11.1.1

Published

check dependency licenses against rules

Downloads

126,418

Readme

licensee

Check npm package dependency license metadata against rules.

Configuration

Licensee accepts two kinds of configuration:

  1. a rule about permitted licenses
  2. a package allowlist of name-and-range pairs

You can set configuration with command flags or a .licensee.json file at the root of your package, like so:

{
  "licenses": {
    "spdx": [
      "MIT",
      "BSD-2-Clause",
      "BSD-3-Clause",
      "Apache-2.0"
    ]
  },
  "packages": {
    "optimist": "<=0.6.1"
  },
  "corrections": false,
  "ignore": [
    {"scope": "kemitchell"},
    {"prefix": "commonform-"},
    {"author": "Kyle E. Mitchell"}
  ]
}

The licenses object adds licenses to an allowlist. Any package with standard license metadata that satisfies that allowlist according to spdx-whitelisted will not cause an error.

Instead of allowlisting each license by SPDX identifier, you can allowlist categories of licenses.

For example, you can specify a minimum Blue Oak Council license rating---lead, bronze, silver, or gold---like so:

{
  "licenses": {
    "blueOak": "bronze"
  }
}

You can combine categories and specific license identifiers, too:

{
  "licenses": {
    "spdx": ["CC-BY-4.0"],
    "blueOak": "gold"
  }
}

The packages property is a map from package name to a node-semver Semantic Versioning range. Packages whose license metadata don't match the SPDX license expression in licenses but have a name and version described in packages will not cause an error.

The corrections flag toggles community corrections to npm package license metadata. When enabled, licensee will check against license values from npm-license-corrections when available, and also use correct-license-metadata to try to correct old-style licenses arrays and other unambiguous, but invalid, metadata.

The optional ignore array instructs licensee to approve packages without considering their license metadata. Ignore rules can take one of three forms:

  1. {"scope":"x"} ignores all packages in scope x, like @x/y.

  2. {"prefix":"x"} ignores all packages whose names start with x, but not scoped packages whose scopes do not match, like @y/x.

  3. {"author":"x"} ignores all packages whose authors' names, e-mail addresses, or URLs contain x.

All ignore rules are case-insensitive.

Use

To install and use licensee globally:

npm install --global licensee
cd your-package
licensee --init
licensee

The licensee script prints a report about dependencies and their license terms to standard output. It exits with status 0 when all packages in ./node_modules meet the configured licensing criteria and 1 when one or more do not.

To install it as a development dependency of your package:

cd your-package
npm install --save-dev licensee

Consider adding licensee to your npm scripts:

{
  "scripts": {
    "posttest": "licensee"
  }
}

To check only production dependencies, ignoring development dependencies, use --production flag:

{
  "scripts": {
    "posttest": "licensee --production"
  }
}

For output as newline-delimited JSON objects, for further processing:

{
  "scripts": {
    "posttest": "licensee --ndjson"
  }
}

To skip the readout of license information:

{
  "scripts": {
    "posttest": "licensee --quiet"
  }
}

If you want a readout of dependency information, but don't want your continuous integration going red, you can ignore licensee's exit code:

{
  "scripts": {
    "posttest": "licensee || true"
  }
}

To save the readout of license information to a file:

{
  "scripts": {
    "posttest": "licensee | tee LICENSES || true"
  }
}

Alternatively, for a readout of just packages without approved licenses:

{
  "scripts": {
    "posttest": "licensee --errors-only"
  }
}

JavaScript Module

The package exports an asynchronous function of three arguments:

  1. A configuration object in the same form as .licensee.json.

  2. The path of the package to check.

  3. An error-first callback that yields an array of objects, one per dependency.