Typescript pdfjs-dist: You may need an additional loader

Viewed 65

I am trying to implement PDF viewer using @react-pdf-viewer/core@3.7.0 which depends on pdfjs-dist@2.15.349. I have installed both libraries but I am getting the following error:

./node_modules/pdfjs-dist/build/pdf.js 1259:21
    Module parse failed: Unexpected token (1259:21)
    File was processed with these loaders:
     * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
    You may need an additional loader to handle the result of these loaders.
    | 
    |         class PixelsPerInch {
    >           static CSS = 96.0;
    |           static PDF = 72.0;
    |           static PDF_TO_CSS_UNITS = this.CSS / this.PDF;

I have tried deleting and reinstalling node_modules, but it did not worked at all. I do not have babel-loader. I am using "typescript": "^4.1.2", "react": "^17.0.2". How can I solve this problem?

0 Answers
Related