Closed wayneashleyberry closed 7 years ago
Same problem.
$ dependency-check package.json
/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:321
throw err;
^
SyntaxError: Unexpected token (21:3)
at raise (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:319:15)
at unexpected (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:1311:5)
at parseExprAtom (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:2070:7)
at parseExprSubscripts (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:1933:28)
at parseMaybeUnary (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:1917:16)
at parseExprOps (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:1875:24)
at parseMaybeConditional (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:1860:16)
at parseMaybeAssign (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:1844:16)
at parseExpression (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:1830:16)
at parseExprAtom (/usr/local/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/acorn.js:2008:17)
hmm im not sure how to debug in this case. I think it would need to be a trial and error thing with the source code in question. @substack any tips on debugging detective
?
Seems like detective
is using a five releases old version of acorn
which in turn seems to have a problem parsing the code of the projects you are running dependecy-check
on and thus fails when it tries to traverse all of the files to find all of the requires()
within the project.
Since acorn
seems to be to blame for this error it could be solve by detective
upgrading to the latest version of acorn
– which eg. this PR in the project requests: https://github.com/substack/node-detective/pull/41
As the PR I mentioned has now been merged and a detective
version with an up to date acorn
dependency has been released as 4.0.1
it would be great if you could update your dependency-check
and check if the reported error still remains.
I ran npm i -g dependency-check
and then tried to use it, and got this:
/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:1011
throw err;
^
SyntaxError: Unexpected token (25:3)
at Parser.pp.raise (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:1009:13)
at Parser.pp.unexpected (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:1496:8)
at Parser.pp.parseExprAtom (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:426:12)
at Parser.pp.parseExprSubscripts (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:321:19)
at Parser.pp.parseMaybeUnary (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:303:19)
at Parser.pp.parseExprOps (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:259:19)
at Parser.pp.parseMaybeConditional (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:242:19)
at Parser.pp.parseMaybeAssign (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:222:19)
at Parser.pp.parseParenAndDistinguishExpression (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:471:28)
at Parser.pp.parseExprAtom (/Users/richard/.nvm/versions/node/v0.12.0/lib/node_modules/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:396:19)
Seems to be the same problem?
I had a similar error.
SyntaxError: Unexpected token (41:12)
at Parser.pp.raise (/Users/jedireza/projects/dependency-check/node_modules/detective/node_modules/acorn/dist/acorn.js:1042:13)
# ...
I console.log
ged some details from inside the pp.raise
function of my local node_modules/detective/node_modules/acorn/dist/acorn.js
file. Specifically the this.input
value and the current arguments
.
In my case it was a .jsx
file that got picked up. And of course, the syntax wouldn't be parseable by acorn
without being transformed first.
As it looks like this issue is caused by a JSX-file or a similar non-standard syntax that's being parsed, I'm will close this now that #61 has been merged and released.
One can now use an alternative detective/parser, such as https://github.com/dependents/node-precinct which amongst other things supports jsx.
Just installed dependency check and tried it out on a project, got this error:
Some debug info:
Oh, and here's my package.json, if that helps.