Javascript react应用程序中pdfjs dist的附加加载程序?

Javascript react应用程序中pdfjs dist的附加加载程序?,javascript,node.js,reactjs,npm,pdfjs-dist,Javascript,Node.js,Reactjs,Npm,Pdfjs Dist,我的react应用程序中存在pdfjs dist依赖项,但它不起作用-我不确定是什么原因导致了这种情况。我正在运行节点v14.16.1,npmv7.9.0,react 17.0.2,react脚本4.0.3,以及pdfjs dist 2.7.570。运行npm start时,我收到以下错误消息: Failed to compile. ./node_modules/pdfjs-dist/build/pdf.js 2407:53 Module parse failed: Unexpected to

我的react应用程序中存在
pdfjs dist
依赖项,但它不起作用-我不确定是什么原因导致了这种情况。我正在运行
节点v14.16.1
npmv7.9.0
react 17.0.2
react脚本4.0.3
,以及
pdfjs dist 2.7.570
。运行
npm start
时,我收到以下错误消息:

Failed to compile.

./node_modules/pdfjs-dist/build/pdf.js 2407:53
Module parse failed: Unexpected token (2407:53)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|                 intent: renderingIntent,
|                 renderInteractiveForms: renderInteractiveForms === true,
>                 annotationStorage: annotationStorage?.getAll() || null
|               });
|             }
我尝试过卸载和重新安装相关软件包,以及
npm update
npm audit
,等等。我还尝试添加了
worker loader
npm包,但它已经是pdfjs dist上的对等依赖项,因此没有任何区别。我在这个项目上的合作伙伴有相同的回购协议,他没有任何问题,所以我相信这是我这边的事情。我相信这与支持可选链接有关,但不确定如何继续。
谢谢

很可能您的网页版本不正确。尝试使用es5构建

我也有同样的问题。我还更新了worker loader和babel loader,但它什么也没做。但是,使用-->const pdfjsLib=window['pdfjs-dist/build/pdf']而不是const pdfjsLib=require('pdfjs-dist/build/pdf.js')可以很好地工作,但显然链接到在线存储库并不是目标