Generate a page with a copy of NPM dependency licenses. Example output
Install:
npm install --global npm-license-generator
Options:
$ npm-license-generator --help
Usage:
npm-license-generator [folder]
Positionals:
folder Folder of NPM project. Defaults to current working directory [string]
Options:
--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: "https://registry.npmjs.org"]
--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]
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 namerenderLicenses
: an array of GroupedLicense. When using--no-group
, an array of LicenseInfo is passed instead.
Check the lib folder for example templates.
- Get package version and tarball location from package.lock
- Look for licenses in node_modules if avalible
- Otherwise download tarball, extract, look for licenses, and use that
- Otherwise, evaluate SPDX string and use a file from https://github.com/spdx/license-list-data/tree/master/text