SyntaxError: Unexpected token '(' when trying to run pdf2json

1.3k Views Asked by At

When I try to run pdf2json (without any parameters at all) I'm getting this error:

/usr/lib/node_modules/pdf2json/lib/p2jcmd.js:63
    #continue(callback, err) {
             ^

SyntaxError: Unexpected token '('
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/lib/node_modules/pdf2json/bin/pdf2json:3:16)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

Here's the Dockerfile I tried to run it in:

FROM debian:bullseye

RUN apt-get update \
    && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
    && apt-get install -y nodejs \
    && npm install pdf2json -g

Any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

Quoting https://github.com/modesty/pdf2json/issues/250:

The problem here is that these were breaking changes but only marked as a new (non-breaking) feature with a minor version increment. So calling npm audit fix actually forces this upgrade and breaks everything. This needs to be re-released as a MAJOR version increment to v2.0 and/or a bug patch released on the 1.x line to make this backwards compatible again.

The solution is to do npm install --save-exact [email protected].