Automatically generate OSS attributions in a Node.js project

One-liner using the license-checker-rseidelsohn package

Hyunbin
2 min readMar 8, 2022

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

--

--

Hyunbin
Hyunbin

Written by Hyunbin

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

No responses yet