kessler / license-report

create a short report about a project's dependencies (license, url etc)
MIT License
227 stars 39 forks source link

Getting an error #15

Closed znat closed 5 years ago

znat commented 5 years ago

Just running licence-report in the project folder

/usr/local/lib/node_modules/license-report/lib/extractLink.js:14
                if (value.substr(0, 'http'.length) === 'http') {
                          ^

TypeError: value.substr is not a function
    at /usr/local/lib/node_modules/license-report/lib/extractLink.js:14:13
    at module.exports (/usr/local/lib/node_modules/license-report/node_modules/visit-values/index.js:20:3)
    at module.exports (/usr/local/lib/node_modules/license-report/node_modules/visit-values/index.js:16:4)
    at module.exports (/usr/local/lib/node_modules/license-report/lib/extractLink.js:13:2)
    at /usr/local/lib/node_modules/license-report/lib/getPackageReportData.js:66:11
    at /usr/local/lib/node_modules/license-report/lib/getPackageJson.js:23:3
    at Stubborn.p._onTaskExecuted (/usr/local/lib/node_modules/license-report/node_modules/stubborn/lib/Stubborn.js:71:18)
    at wrapper (/usr/local/lib/node_modules/license-report/node_modules/lodash/lodash.js:4935:19)
    at /usr/local/lib/node_modules/license-report/node_modules/lodash/lodash.js:10052:25
    at Request._callback (/usr/local/lib/node_modules/license-report/lib/getPackageJson.js:56:11)
kessler commented 5 years ago

Does not reproduce... could you provide more details? (maybe the package.json you're using)

liias commented 5 years ago

I have same issue, using node 10.15.0

/home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/lib/extractLink.js:14
        if (value.substr(0, 'http'.length) === 'http') {
                  ^

TypeError: value.substr is not a function
    at /home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/lib/extractLink.js:14:13
    at module.exports (/home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/node_modules/visit-values/index.js:20:3)
    at module.exports (/home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/node_modules/visit-values/index.js:16:4)
    at module.exports (/home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/lib/extractLink.js:13:2)
    at /home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/lib/getPackageReportData.js:66:11
    at /home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/lib/getPackageJson.js:22:3
    at Stubborn.p._onTaskExecuted (/home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/node_modules/stubborn/lib/Stubborn.js:71:18)
    at wrapper (/home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/node_modules/lodash/lodash.js:4935:19)
    at /home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/node_modules/lodash/lodash.js:10052:25
    at Request._callback (/home/madis/.nvm/versions/node/v10.15.0/lib/node_modules/license-report/lib/getPackageJson.js:55:11)

This library is causing the issue in package.json dependencies: "rxjs-compat": "^6.3.3",

morficus commented 5 years ago

I'm having the same issue (also using node 10.15.0).

It seems like the issue is is here: /lib/extractLink.js#L14

The argument of value which is given to the callback is not always a string. In my particular case I sometimes see a Boolean passed in... which causes things to break.

In my case this is the offender (object truncated since the rest is no relevant):

{
    name: 'vuedraggable',
    version: '2.21.0',
    description: 'draggable component for vue',
    main: 'dist/vuedraggable.umd.min.js',
    private: false,
    scripts: {}
}

So when that gets passed in the visit()... the callback throws an error when trying to call the substr function on the property "private" which is a boolean.