License List
List licenses for installed packages.
Features
- JSON, CSV, XML or ASCII table output
- Specify the package depth
- Ability to limit list to only dev or only production packages
- Support for converting SPDX expressions in to their full names
- Specify what properties should be included in the out
- Can be used programmatically for maximum flex- and extensibility
Options
You can always run npx license-ls --help
to get this documentation
--help
: show help--format
: output format. json, table, xml or csv (defaults to table)--include
: List of properties to include--depth
: Max display depth of the dependency tree--production, --prod
: Display only the dependency tree for packages in dependencies--development, --dev
: Display only the dependency tree for packages in devDependencies--global
: List packages in the global install prefix instead of in the current project--link
: Display only dependencies which are linked
CSV specific options
--csv.delimiter
: character the use as the value separator (defaults to,
)
Table specific options
--table.header.*
: changes the default header name for table output (ie:--header.name=Module
)- Here is a list of possible values for
*
:id
,name
,version
,license
,homepage
,repository
,author
,dependencyLevel
,description
- Here is a list of possible values for
XML specific options
--xml.asAttrs
: uses each package property as the XML tag element, with the package name as the content (see "XML Output #2" in the Examples section)
Examples
Get a list of all dependency packages
npx license-ls
Get a list of only direct dependencies
npx license-ls --depth=0
Get a list of only direct production dependencies
npx license-ls --depth=0 --prod
Get a list of only direct production dependencies, only show directory path, name and license
npx license-ls --depth=0 --prod --include=path,name,license
Get a list of all dependency packages in JSON format
npx license-ls --format=json
Save results to a file
npx license-ls --depth=0 > report.txt
Set some custom table headers
npx license-ls --depth=0 --table.header.name=Module --table.header.repository="Repo URL" --table.header.author="Who made this?"
Sample Output formats
All of the following samples were generated by running the relevant command against this project.
JSON output
npx license-ls --format=json --depth=0
CSV output
npx license-ls --format=csv --depth=0
"id","name","version","license","repository","author","homepage","path","dependencyLevel"0,"ava","2.1.0","MIT License (MIT)","git+https://github.com/avajs/ava.git",,"https://avajs.dev","/Users/morficus/workspace/license-ls/node_modules/ava","development"1,"debug","4.1.1","MIT License (MIT)","git://github.com/visionmedia/debug.git","TJ Holowaychuk","https://github.com/visionmedia/debug#readme","/Users/morficus/workspace/license-ls/node_modules/debug","development"2,"json2csv","4.5.1","MIT License (MIT)","git+https://github.com/zemirco/json2csv.git","Mirco Zeiss","https://github.com/zemirco/json2csv#readme","/Users/morficus/workspace/license-ls/node_modules/json2csv","production"3,"jstoxml","1.5.0","MIT License (MIT)","git://github.com/davidcalhoun/jstoxml.git","David Calhoun","http://github.com/davidcalhoun/jstoxml","/Users/morficus/workspace/license-ls/node_modules/jstoxml","production"4,"libnpm","2.0.1","ISC License (ISC)","git+https://github.com/npm/libnpm.git","Kat Marchán","https://github.com/npm/libnpm#readme","/Users/morficus/workspace/license-ls/node_modules/libnpm","production"5,"nyc","14.1.1","ISC License (ISC)","git+ssh://git@github.com/istanbuljs/nyc.git","Ben Coe","https://github.com/istanbuljs/nyc#readme","/Users/morficus/workspace/license-ls/node_modules/nyc","production"6,"ora","3.4.0","MIT License (MIT)","git+https://github.com/sindresorhus/ora.git","Sindre Sorhus","https://github.com/sindresorhus/ora#readme","/Users/morficus/workspace/license-ls/node_modules/ora","production"7,"read-package-tree","5.2.2","ISC License (ISC)","git+https://github.com/npm/read-package-tree.git","Isaac Z. Schlueter","https://github.com/npm/read-package-tree","/Users/morficus/workspace/license-ls/node_modules/read-package-tree","production"8,"spdx-expression-parse","3.0.0","MIT License (MIT)","git+https://github.com/jslicense/spdx-expression-parse.js.git","Kyle E. Mitchell","https://github.com/jslicense/spdx-expression-parse.js#readme","/Users/morficus/workspace/license-ls/node_modules/spdx-expression-parse","production"9,"spdx-license-list","6.0.0","Creative Commons Zero v1.0 Universal (CC0-1.0)","git+https://github.com/sindresorhus/spdx-license-list.git","Sindre Sorhus","https://github.com/sindresorhus/spdx-license-list#readme","/Users/morficus/workspace/license-ls/node_modules/spdx-license-list","production"10,"table","5.4.1","BSD 3-Clause ""New"" or ""Revised"" License (BSD-3-Clause)","git+https://github.com/gajus/table.git","Gajus Kuizinas","https://github.com/gajus/table#readme","/Users/morficus/workspace/license-ls/node_modules/table","production"11,"yargs","13.2.4","MIT License (MIT)","git+https://github.com/yargs/yargs.git",,"https://yargs.js.org/","/Users/morficus/workspace/license-ls/node_modules/yargs","production"
Table output
npx license-ls --depth=0
╔═══════╤═══════════════════════╤═════════╤════════════════════════════════════════════════════════╤═══════════════════════════════════════════════════════════════╤════════════════════╤══════════════════════════════════════════════════════════════╤════════════════════════════════════════════════════════════════════════════════╤═════════════════╗║ Row # │ Package Name │ Version │ License │ Repository │ Author │ Homepage │ │ Dependency type ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 0 │ ava │ 2.1.0 │ MIT License (MIT) │ git+https://github.com/avajs/ava.git │ │ https://avajs.dev │ /Users/morficus/workspace/license-ls/node_modules/ava │ development ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 1 │ debug │ 4.1.1 │ MIT License (MIT) │ git://github.com/visionmedia/debug.git │ TJ Holowaychuk │ https://github.com/visionmedia/debug#readme │ /Users/morficus/workspace/license-ls/node_modules/debug │ development ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 2 │ json2csv │ 4.5.1 │ MIT License (MIT) │ git+https://github.com/zemirco/json2csv.git │ Mirco Zeiss │ https://github.com/zemirco/json2csv#readme │ /Users/morficus/workspace/license-ls/node_modules/json2csv │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 3 │ jstoxml │ 1.5.0 │ MIT License (MIT) │ git://github.com/davidcalhoun/jstoxml.git │ David Calhoun │ http://github.com/davidcalhoun/jstoxml │ /Users/morficus/workspace/license-ls/node_modules/jstoxml │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 4 │ libnpm │ 2.0.1 │ ISC License (ISC) │ git+https://github.com/npm/libnpm.git │ Kat Marchán │ https://github.com/npm/libnpm#readme │ /Users/morficus/workspace/license-ls/node_modules/libnpm │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 5 │ nyc │ 14.1.1 │ ISC License (ISC) │ git+ssh://git@github.com/istanbuljs/nyc.git │ Ben Coe │ https://github.com/istanbuljs/nyc#readme │ /Users/morficus/workspace/license-ls/node_modules/nyc │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 6 │ ora │ 3.4.0 │ MIT License (MIT) │ git+https://github.com/sindresorhus/ora.git │ Sindre Sorhus │ https://github.com/sindresorhus/ora#readme │ /Users/morficus/workspace/license-ls/node_modules/ora │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 7 │ read-package-tree │ 5.2.2 │ ISC License (ISC) │ git+https://github.com/npm/read-package-tree.git │ Isaac Z. Schlueter │ https://github.com/npm/read-package-tree │ /Users/morficus/workspace/license-ls/node_modules/read-package-tree │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 8 │ spdx-expression-parse │ 3.0.0 │ MIT License (MIT) │ git+https://github.com/jslicense/spdx-expression-parse.js.git │ Kyle E. Mitchell │ https://github.com/jslicense/spdx-expression-parse.js#readme │ /Users/morficus/workspace/license-ls/node_modules/spdx-expression-parse │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 9 │ spdx-license-list │ 6.0.0 │ Creative Commons Zero v1.0 Universal (CC0-1.0) │ git+https://github.com/sindresorhus/spdx-license-list.git │ Sindre Sorhus │ https://github.com/sindresorhus/spdx-license-list#readme │ /Users/morficus/workspace/license-ls/node_modules/spdx-license-list │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 10 │ table │ 5.4.1 │ BSD 3-Clause "New" or "Revised" License (BSD-3-Clause) │ git+https://github.com/gajus/table.git │ Gajus Kuizinas │ https://github.com/gajus/table#readme │ /Users/morficus/workspace/license-ls/node_modules/table │ production ║╟───────┼───────────────────────┼─────────┼────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────┼────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────┼─────────────────╢║ 11 │ yargs │ 13.2.4 │ MIT License (MIT) │ git+https://github.com/yargs/yargs.git │ │ https://yargs.js.org/ │ /Users/morficus/workspace/license-ls/node_modules/yargs │ production ║╚═══════╧═══════════════════════╧═════════╧════════════════════════════════════════════════════════╧═══════════════════════════════════════════════════════════════╧════════════════════╧══════════════════════════════════════════════════════════════╧════════════════════════════════════════════════════════════════════════════════╧═════════════════╝
XML Output #1
npx license-ls --depth=0 --format=xml
0 ava 2.1.0 MIT License (MIT) git+https://github.com/avajs/ava.git https://avajs.dev /Users/morficus/workspace/license-ls/node_modules/ava development 1 debug 4.1.1 MIT License (MIT) git://github.com/visionmedia/debug.git TJ Holowaychuk https://github.com/visionmedia/debug#readme /Users/morficus/workspace/license-ls/node_modules/debug development 2 json2csv 4.5.1 MIT License (MIT) git+https://github.com/zemirco/json2csv.git Mirco Zeiss https://github.com/zemirco/json2csv#readme /Users/morficus/workspace/license-ls/node_modules/json2csv production 3 jstoxml 1.5.0 MIT License (MIT) git://github.com/davidcalhoun/jstoxml.git David Calhoun http://github.com/davidcalhoun/jstoxml /Users/morficus/workspace/license-ls/node_modules/jstoxml production 4 libnpm 2.0.1 ISC License (ISC) git+https://github.com/npm/libnpm.git Kat Marchán https://github.com/npm/libnpm#readme /Users/morficus/workspace/license-ls/node_modules/libnpm production 5 nyc 14.1.1 ISC License (ISC) git+ssh://git@github.com/istanbuljs/nyc.git Ben Coe https://github.com/istanbuljs/nyc#readme /Users/morficus/workspace/license-ls/node_modules/nyc production 6 ora 3.4.0 MIT License (MIT) git+https://github.com/sindresorhus/ora.git Sindre Sorhus https://github.com/sindresorhus/ora#readme /Users/morficus/workspace/license-ls/node_modules/ora production 7 read-package-tree 5.2.2 ISC License (ISC) git+https://github.com/npm/read-package-tree.git Isaac Z. Schlueter https://github.com/npm/read-package-tree /Users/morficus/workspace/license-ls/node_modules/read-package-tree production 8 spdx-expression-parse 3.0.0 MIT License (MIT) git+https://github.com/jslicense/spdx-expression-parse.js.git Kyle E. Mitchell https://github.com/jslicense/spdx-expression-parse.js#readme /Users/morficus/workspace/license-ls/node_modules/spdx-expression-parse production 9 spdx-license-list 6.0.0 Creative Commons Zero v1.0 Universal (CC0-1.0) git+https://github.com/sindresorhus/spdx-license-list.git Sindre Sorhus https://github.com/sindresorhus/spdx-license-list#readme /Users/morficus/workspace/license-ls/node_modules/spdx-license-list production 10 table 5.4.1 BSD 3-Clause "New" or "Revised" License (BSD-3-Clause) git+https://github.com/gajus/table.git Gajus Kuizinas https://github.com/gajus/table#readme /Users/morficus/workspace/license-ls/node_modules/table production 11 yargs 13.2.4 MIT License (MIT) git+https://github.com/yargs/yargs.git https://yargs.js.org/ /Users/morficus/workspace/license-ls/node_modules/yargs production
XML Output #2
npx license-ls --depth=0 --format=xml --xml.asAttrs
ava debug json2csv jstoxml libnpm nyc ora read-package-tree spdx-expression-parse spdx-license-list table yargs
Using as a library
You can use all of the same CLI options when using license-ls
as a module (with the exception of anything that is specific to out format - such as include
or format
).
When using it as a module, the function will always return a promise that resolves to an Array and will include all properties (['id', 'name', 'version', 'license', 'repository', 'author', 'homepage', 'path', 'dependencyLevel', 'description']
)
const licenseLs = const options = depth: 1 prod: true
Contributing
Want a new feature added? Found a bug? Go ahead an open a new issue or feel free to submit a pull request