Automatically generate OSS attributions in a Node.js project

TL;DR

In the terminal, type the following one-liner.

npx license-checker-rseidelsohn --direct

Used license-checker-rseidelsohn instead of license-checker since it fixes the direct option, which only looks for dependencies in the package.json file.

Tips

Exclude Package

Specifying version value in package.json includes the current project in the output. Remove the version value, or use the excludePackages option.

--excludePackages 'package-name-goes-here'

Markdown Generation

Using markdown and out option to generate a license.md file.

// Terminal
npx license-checker-rseidelsohn --direct --markdown --out license.md
// license.md
[eslint@7.32.0](https://github.com/eslint/eslint) - MIT
[postcss@8.4.7](https://github.com/postcss/postcss) - MIT

Auto-run After Install

Add npx license-checker-rseidelsohn to the postinstall script. Options can be passed, so the above ‘Markdown Generation’ code can be used.

// package.json
{
"scripts": {
"postinstall": "npx license-checker-rseidelsohn"
},

Note that the postinstall script will not be executed when specific packages are installed with the npm install [<@scope>/]<pkg> and related commands. Manually execute npm install or npm run postinstall afterwards in order to overcome this restriction. (After all, postinstall is just another script.)

Examples

Open Source Licenses, Samsung Developers

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hyunbin

Hyunbin

Node.js and web developer using TypeScript. Undergraduate in Seoul National University.