https://github.com/gabts/node-modules-license-crawler
Crawl dependency licenses from node_modules
https://github.com/gabts/node-modules-license-crawler
Last synced: 10 months ago
JSON representation
Crawl dependency licenses from node_modules
- Host: GitHub
- URL: https://github.com/gabts/node-modules-license-crawler
- Owner: gabts
- License: mit
- Created: 2020-10-16T19:12:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-10T13:39:41.000Z (over 5 years ago)
- Last Synced: 2025-07-25T00:23:49.390Z (11 months ago)
- Language: TypeScript
- Homepage: https://npmjs.com/package/node-modules-license-crawler
- Size: 10.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node Modules License Crawler
Crawls dependencies recursively from your package.json file and finds license texts from packages in node_modules. Note: development and peer dependencies are skipped.
## Install
```sh
npm install node-modules-license-crawler
```
## Usage
```js
var fs = require("fs");
var nodeModulesLicenseCrawler = require("node-modules-license-crawler");
var data = nodeModulesLicenseCrawler();
fs.writeFileSync("./licenses.json", JSON.stringify(data));
```
## Sample output
If [`react`](https://github.com/facebook/react) was your only dependency the output would look like this. The modules text value refers to an index in the texts array. This is for if you want to save some space as you often have a few modules with the same exact license text content (like `react` and `react-is` does here).
Modules where we couldn't find a license have text value `null` instead of an index number.
```json
{
"modules": [
{
"name": "js-tokens",
"version": "4.0.0",
"license": "MIT",
"text": 2
},
{
"name": "loose-envify",
"version": "1.4.0",
"license": "MIT",
"text": 1
},
{
"name": "object-assign",
"version": "4.1.1",
"license": "MIT",
"text": 3
},
{
"name": "prop-types",
"version": "15.7.2",
"license": "MIT",
"text": 4
},
{
"name": "react",
"version": "16.14.0",
"license": "MIT",
"text": 0
},
{
"name": "react-is",
"version": "16.13.1",
"license": "MIT",
"text": 0
}
],
"texts": [
"MIT License\n\nCopyright (c) Facebook, Inc. and its affiliates.\n ...",
"The MIT License (MIT)\n\nCopyright (c) 2015 Andres Suarez