### Install and Run License Checker Source: https://github.com/davglass/license-checker/blob/master/README.md Demonstrates how to globally install the `license-checker` tool and run it in a new project to inspect dependency licenses. ```shell npm install -g license-checker mkdir foo cd foo npm install yui-lint license-checker ``` -------------------------------- ### License Checker Command-Line Usage Examples Source: https://github.com/davglass/license-checker/blob/master/README.md Practical examples demonstrating how to use various command-line options with `license-checker` to achieve different output formats, filtering, and exclusions. ```shell 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 ``` -------------------------------- ### Example Console Output of License Checker Source: https://github.com/davglass/license-checker/blob/master/README.md Illustrates the default console output format of `license-checker`, showing dependency names, repositories, and identified licenses. ```text ├─ 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 ├─ jshint@0.9.1 │ └─ 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 ``` -------------------------------- ### Example Console Output with Deduced License Source: https://github.com/davglass/license-checker/blob/master/README.md Shows an example of `license-checker` output where an asterisk indicates a license deduced from files other than `package.json`. ```text └─ debug@2.0.0 ├─ repository: https://github.com/visionmedia/debug └─ licenses: MIT* ``` -------------------------------- ### Programmatic Usage of License Checker (Node.js) Source: https://github.com/davglass/license-checker/blob/master/README.md Demonstrates how to programmatically use the `license-checker` module in a Node.js application, initializing it with a start path and handling the callback for results or errors. ```javascript var checker = require('license-checker'); checker.init({ start: '/path/to/start/looking' }, function(err, packages) { if (err) { //Handle error } else { //The sorted package data //as an Object } }); ``` -------------------------------- ### License Checker Command-Line Options Source: https://github.com/davglass/license-checker/blob/master/README.md Comprehensive list of command-line arguments available for the `license-checker` tool, allowing users to filter, format, and control output. ```APIDOC --production: Only show production dependencies. --development: Only show development dependencies. --start [path of the initial json to look for]: Specifies the path of the initial package.json to start looking from. --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. --out [filepath]: Write the data to a specific file. --customPath: Path to a custom format file in JSON. --exclude [list]: Exclude modules whose licenses are in the semicolon-separated list from the output. Supports SPDX identifiers and expressions, and non-SPDX strings. --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-separated list. --packages [list]: Restrict output to the packages (package@version) in the semicolon-separated list. --excludePackages [list]: Restrict output to the packages (package@version) not in the semicolon-separated list. --excludePrivatePackages: Restrict output to not include any package marked as private. --direct: Look for direct dependencies only. ``` -------------------------------- ### Enable Debugging and View Scan Output for license-checker Source: https://github.com/davglass/license-checker/blob/master/README.md This shell command demonstrates how to activate verbose debug logging for the `license-checker` utility by setting the `DEBUG` environment variable. The output illustrates a typical scan result, detailing identified packages, their repositories, and detected licenses, providing insight into the tool's operation. ```shell $ export DEBUG=license-checker*; license-checker scanning ./yui-lint ├─ cli@0.4.3 │ ├─ repository: http://github.com/chriso/cli │ └─ licenses: MIT # ... ``` -------------------------------- ### License Checker Custom Output Format Fields Source: https://github.com/davglass/license-checker/blob/master/README.md Details the available fields that can be used when defining a custom output format for `license-checker` via the `--customPath` option, including default value support. ```APIDOC Available items for custom format: - name: Package name. - version: Package version. - description: Package description. - repository: Package repository URL. - publisher: Package publisher. - email: Publisher's email. - url: Package URL. - licenses: License string. - licenseFile: Path to the license file. - licenseText: Full license text. - licenseModified: Boolean indicating if the license was modified. Default values can also be provided for each item. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.