When using the '--onlyDirectDependencies' option on a project with a package.json that has no 'dependencies' field (e.g a project that only has devDependencies), the following error is thrown:
/usr/local/lib/node_modules/npm-license-crawler/lib/index.js:23
onlyDirectDependenciesFilter[packageJsonContents.name] = Object.keys(packageJsonContents.dependencies);
^
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at DirectoryReader.<anonymous> (/usr/local/lib/node_modules/npm-license-crawler/lib/index.js:23:85)
at DirectoryReader.emit (events.js:180:13)
at /usr/local/lib/node_modules/npm-license-crawler/lib/directoryreader.js:145:26
at FSReqWrap.oncomplete (fs.js:171:5)
It seems like this is down to the packageJsonContents.dependencies condition in the if-statement at line 23 of 'index.js' being insufficient. Adding a typeof packageJsonContents.dependencies !== 'undefined' condition should resolve this.
When using the '--onlyDirectDependencies' option on a project with a package.json that has no 'dependencies' field (e.g a project that only has devDependencies), the following error is thrown:
It seems like this is down to the
packageJsonContents.dependencies
condition in the if-statement at line 23 of 'index.js' being insufficient. Adding atypeof packageJsonContents.dependencies !== 'undefined'
condition should resolve this.