Generate HTML with license text from NPM dependencies

Usage no npm install needed!

<script type="module">
  import npmLicenseGenerator from '';


NPM License Generator

Generate a page with a copy of NPM dependency licenses. Example output



npm install --global npm-license-generator


$ npm-license-generator --help

  npm-license-generator [folder]

  folder  Folder of NPM project. Defaults to current working directory  [string]

  --version          Show version number                               [boolean]
  --help             Show help                                         [boolean]
  --out-path         HTML output path      [string] [default: "./licenses.html"]
  --registry         URL of package registry to use
                                [string] [default: ""]
  --tmp-folder-name  Name of temporary folder
                                          [string] [default: ".license-gen-tmp"]
  --template         Path to custom mustache template                   [string]
  --no-group         Do not group licenses            [boolean] [default: false]
  --package-lock     Run on all packages listed in package-lock.json
                                                      [boolean] [default: false]
  --no-spdx          Do not download license file based on SPDX string
                                                      [boolean] [default: false]
  --only-spdx        Do not download tarballs, only use SPDX string
                                                      [boolean] [default: false]
  --error-missing    Exit 1 if no license is present for a package
                                                      [boolean] [default: false]

Use your own template

Supply your own template using the --template option. Templates are written in Mustache. Your template does not have to be HTML, change the output file name using --out-path.

By default, Mustache is given two variables:

  • name: the package name
  • renderLicenses: an array of GroupedLicense. When using --no-group, an array of LicenseInfo is passed instead.

Check the lib folder for example templates.

How licenses are found

  1. Get package version and tarball location from package.lock
  2. Look for licenses in node_modules if avalible
  3. Otherwise download tarball, extract, look for licenses, and use that
  4. Otherwise, evaluate SPDX string and use a file from