3

Following error is obtained when trying to build project using 'pdfjs-dist' npm module in Angular

Module parse failed: Unexpected token (2413:45)
File was processed with these loaders:
 * ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
 * ./node_modules/@ngtools/webpack/src/ivy/index.js
You may need an additional loader to handle the result of these loaders.
|         intent: renderingIntent,
|         renderInteractiveForms: renderInteractiveForms === true,
>         annotationStorage: annotationStorage?.getAll() || null
|       });
|     } 

How to resolve this? Any workarounds or suggestions would help a lot!

3 Answers 3

1

This error can be fixed by downgrading the version of 'pdfjs-dist' module version from 2.7.570 to a lower stable version say 2.5.207.

Another fix could be upgrading the version of webpack from 4.x to 5.x, but this is not a recommended solution as this can create issues with the other dependent modules of the project.

Sign up to request clarification or add additional context in comments.

Comments

0

As mentionned in this Github issue, one of the solutions might be adding this change to your package.json:

// changing 
"pdfjs-dist": "^2.6.347",
// to
"pdfjs-dist": "2.6.347",

Comments

-1

I had encountered the same error. This worked for me, might work for you

-----------use these lines---------

"fileReplacements": [
       {
                "replace": "./node_modules/jspdf/dist/jspdf.es.min.js",
                "with": "./node_modules/jspdf/dist/jspdf.umd.min.js"
              }
],

In angular.json file,

"build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
place the above code here....
........
}

1 Comment

The package you are mentioning, jspdf, is something different than pdfjs. Those files aren't present in pdfjs-dist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.