Answer the question
In order to leave comments, you need to log in
React (create-react-app) why is there a compilation error?
Good afternoon,
I can not figure out the error.
Added a third-party react-pdf module to the application that uses pdf.js.
After some time, when running npm start, an error began to appear in pdf.worker.js:
Line 815:18: Unexpected use of 'self' no-restricted-globals
Line 816:25: Unexpected use of 'self' no-restricted-globals
Line 818:51: Unexpected use of 'self' no-restricted-globals
/*eslint-disable*/
import {Document, Page, pdfjs} from 'react-pdf';
import pdfjsWorker from '../../build/pdf.worker.entry';
pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
Answer the question
In order to leave comments, you need to log in
The solution may be useful to someone:
import {Document, Outline, Page, pdfjs} from 'react-pdf';
import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry';
pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question