license-checker icon indicating copy to clipboard operation
license-checker copied to clipboard

Error when using exclude

Open jamietre opened this issue 6 years ago • 5 comments

Hard to reproduce in a way that gives me much insight on what exactly is the issue; some specific things fail, others don't. For example:

> license-checker --exclude 'GPL-2.0'
/Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/node_modules/spdx-expression-parse/parse.js:52
    if (t.type === 'DOCUMENTREF') {
          ^

TypeError: Cannot read property 'type' of null
    at parseLicenseRef (/Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/node_modules/spdx-expression-parse/parse.js:52:11)
    at parseAtom (/Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/node_modules/spdx-expression-parse/parse.js:102:7)
    at parseBinaryOp (/Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/node_modules/spdx-expression-parse/parse.js:109:18)
    at parseBinaryOp (/Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/node_modules/spdx-expression-parse/parse.js:109:18)
    at module.exports (/Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/node_modules/spdx-expression-parse/parse.js:133:14)
    at module.exports (/Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/node_modules/spdx-expression-parse/index.js:7:10)
    at module.exports (/Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/node_modules/spdx-satisfies/index.js:110:29)
    at /Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/lib/index.js:383:40
    at Array.forEach (<anonymous>)
    at /Users/jamiet/.nvm/versions/node/v8.9.4/lib/node_modules/license-checker/lib/index.js:367:30

There is a package with this license: (GPL-2.0 OR MIT)

  • running it with just MIT works: > license-checker --exclude 'MIT'
  • running it with a random single string also fails, e.g. > license-checker --exclude 'FOO'
  • running it with a random string + MIT works: > license-checker --exclude 'FOO, MIT'

jamietre avatar May 10 '18 13:05 jamietre

I have the same issue, running the example from the read me license-checker --exclude 'MIT, MIT OR X11, BSD, ISC' crashes with the error pasted above.

Even if I just run it with 'MIT' as the only parameter.

I've just noticed it seems to work if I use double quotes: license-checker --exclude "MIT, MIT OR X11, BSD, ISC"

DesHorsley avatar May 27 '18 23:05 DesHorsley

I encounter the same problem with the latest version 24.0.1 with license-checker:

license-checker --production --exclude "MIT;BSD-3-Clause"
/home/foo/bar/node_modules/spdx-expression-parse/parse.js:52
    if (t.type === 'DOCUMENTREF') {
          ^

TypeError: Cannot read property 'type' of null
    at parseLicenseRef (/home/foo/bar/node_modules/spdx-expression-parse/parse.js:52:11)
    at parseAtom (/home/foo/bar/node_modules/spdx-expression-parse/parse.js:102:7)
    at parseBinaryOp (/home/foo/bar/node_modules/spdx-expression-parse/parse.js:109:18)
    at parseBinaryOp (/home/foo/bar/node_modules/spdx-expression-parse/parse.js:109:18)
    at module.exports (/home/foo/bar/node_modules/spdx-expression-parse/parse.js:133:14)
    at module.exports (/home/foo/bar/node_modules/spdx-expression-parse/index.js:7:10)
    at module.exports (/home/foo/bar/node_modules/spdx-satisfies/index.js:110:29)
    at /home/foo/bar/node_modules/license-checker/lib/index.js:389:64
    at Array.forEach (<anonymous>)
    at /home/foo/bar/node_modules/license-checker/lib/index.js:375:30

cmur2 avatar Nov 16 '18 12:11 cmur2

I'm not sure this is an issue with license-checker itself or if it's the spdx-satisfies module. The line that throws the error is:

 } else if (spdxCorrect(license) && spdxSatisfies(spdxCorrect(license), spdxExcluder)) {

That to me means that the spdx-satisfies isn't doing the right thing.

davglass avatar Nov 16 '18 13:11 davglass

That could be true, I circumvented for now using license-checker --production --exclude "MIT OR ISC OR Apache-2.0" with the spdx syntax and that seems to work for my use case...

cmur2 avatar Nov 16 '18 13:11 cmur2

On Windows using " instead of ' is working for me. Use \" in package.json for correct syntax.

TorstenDittmann avatar Dec 04 '19 17:12 TorstenDittmann