Output all licenses of installed node.js libraries

Yarn has a command for this as well. yarn licenses list renders short output, yarn licenses generate-disclaimer renders all the actual license text to stdout (suitable for disclaimers, as the option would imply).

  • If you want to omit devDependencies:

    NODE_ENV=production yarn licenses list
    
  • For my purposes, the following command got me close enough:

    yarn licenses list | grep License | \
    grep -vE 'MIT|ISC|WTFPL|BSD|Apache|Unlicense|CC-BY|Public Domain'`
    

cd {project}/node_modules
ls | sed 's/$/\/package.json/' | xargs grep '"license[s]*"' -A 3

Could use some improvement, but it works (at least on osx, should work on linux, no idea about windows). You should see something like:

grunt/package.json:  "licenses": [
grunt/package.json-    {
grunt/package.json-      "type": "MIT",
grunt/package.json-      "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT"
--
grunt-contrib-concat/package.json:  "licenses": [
grunt-contrib-concat/package.json-    {
grunt-contrib-concat/package.json-      "type": "MIT",
grunt-contrib-concat/package.json-      "url": "https://github.com/gruntjs/grunt-contrib-concat/blob/master/LICENSE-MIT"
--

Update:

If you wish to see the name of all modules, even those nested inside other modules, the following works (cred to @robertklep, slightly modified to still work when inside the node_modules directory):

find * -name package.json | xargs grep '"license[s]*"' -A 3

I had exactly the same requirement, and wrote a node module to do this. Shameless self promotion I know, but it is open source and hope it can help resolve your issue. Let me know if you have any issues or suggestions.

The difference over the other answers is that it does not just use the package.json license declaration, but looks for potential license information in license and readme files in the project.

https://npmjs.org/package/nlf

You can install using npm install -g nlf

Tags:

Node.Js

Npm