← 全部工具

license-checker

热度 65 更新于 开发与构建

Check license info for a package

npmauto-collected

安装

npm
npm install -g license-checker

通过 npm 安装。

NPM License Checker ===================

As of v17.0.0 the failOn and onlyAllow arguments take semicolons as delimeters instead of commas. Some license names contain commas and it messed with the parsing

Ever needed to see all the license info for a module and its dependencies?

It's this easy:

npm install -g license-checker

mkdir foo
cd foo
npm install yui-lint
license-checker

You should see something like this:

├─ cli@0.4.3
│  ├─ repository: http://github.com/chriso/cli
│  └─ licenses: MIT
├─ glob@3.1.14
│  ├─ repository: https://github.com/isaacs/node-glob
│  └─ licenses: UNKNOWN
├─ graceful-fs@1.1.14
│  ├─ repository: https://github.com/isaacs/node-graceful-fs
│  └─ licenses: UNKNOWN
├─ inherits@1.0.0
│  ├─ repository: https://github.com/isaacs/inherits
│  └─ licenses: UNKNOWN

│ └─ licenses: MIT ├─ lru-cache@1.0.6 │ ├─ repository: https://github.com/isaacs/node-lru-cache │ └─ licenses: MIT ├─ lru-cache@2.0.4 │ ├─ repository: https://github.com/isaacs/node-lru-cache │ └─ licenses: MIT ├─ minimatch@0.0.5 │ ├─ repository: https://github.com/isaacs/minimatch │ └─ licenses: MIT ├─ minimatch@0.2.9 │ ├─ repository: https://github.com/isaacs/minimatch │ └─ licenses: MIT ├─ sigmund@1.0.0 │ ├─ repository: https://github.com/isaacs/sigmund │ └─ licenses: UNKNOWN └─ yui-lint@0.1.1 ├─ licenses: BSD └─ repository: http://github.com/yui/yui-lint


An asterisk next to a license name means that it was deduced from
an other file than package.json (README, LICENSE, COPYING, ...)
You could see something like this:

└─ debug@2.0.0 ├─ repository: https://github.com/visionmedia/debug └─ licenses: MIT


Options
-------

* `--production` only show production dependencies.
* `--development` only show development dependencies.
* `--start [path of the initial json to look for]`
* `--unknown` report guessed licenses as unknown licenses.
* `--onlyunknown` only list packages with unknown or guessed licenses.
* `--json` output in json format.
* `--csv` output in csv format.
* `--csvComponentPrefix` prefix column for component in csv format.
  • --customPath to add a custom Format file in JSON
  • --exclude [list] exclude modules which licenses are in the comma-separated list from the output
  • --relativeLicensePath output the location of the license files as relative paths
  • --summary output a summary of the license usage',
  • --failOn [list] fail (exit with code 1) on the first occurrence of the licenses of the semicolon-separated list
  • --onlyAllow [list] fail (exit with code 1) on the first occurrence of the licenses not in the semicolon-seperated list
  • --packages [list] restrict output to the packages (package@version) in the semicolon-seperated list
  • --excludePackages [list] restrict output to the packages (package@version) not in the semicolon-seperated list
  • --excludePrivatePackages restrict output to not include any package marked as private
  • --direct look for direct dependencies only

Exclusions ---------- A list of licenses is the simplest way to describe what you want to exclude.

You can use valid SPDX identifiers. You can use valid SPDX expressions like MIT OR X11. You can use non-valid SPDX identifiers, like Public Domain, since npm does support some license strings that are not SPDX identifiers.

Examples --------

license-checker --json > /path/to/licenses.json
license-checker --csv --out /path/to/licenses.csv
license-checker --unknown
license-checker --customPath customFormatExample.json
license-checker --exclude 'MIT, MIT OR X11, BSD, ISC'
license-checker --packages 'react@16.3.0;react-dom@16.3.0;lodash@4.3.1'
license-checker --excludePackages 'internal-1;internal-2'
license-checker --onlyunknown

Custom format -------------