javascript - react 应用程序中 pdfjs-dist 的附加加载器?

标签 javascript node.js reactjs npm pdfjs-dist

我有 pdfjs-dist我的 react 应用程序中的依赖项并且它不起作用 - 我不确定我改变了什么导致这个。我正在运行 node v14.16.1 , npm v7.9.0 , react 17.0.2 , react-scripts 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 的对等依赖,所以它没有区别。我在这个项目上的合作伙伴有相同的 repo ,他没有任何问题,所以我确信这是我的目标。我相信这与对可选链接的支持有关,但不确定如何进行。
谢谢!

最佳答案

我只是偶然发现了同样的问题。我所做的是还原 pdfjs-dist到较早的版本(在我的情况下,2.9.359 回到 2.6.347)。现在一切正常,希望对某人有所帮助。
类似案例的可能解释可以在另一个 question 中找到。 .

关于javascript - react 应用程序中 pdfjs-dist 的附加加载器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67114898/

相关文章:

javascript - 插入或保存到 mongodb 返回 500 服务器错误

reactjs - 将内联 reducer 函数传递给 React.useReducer

javascript - AngularJS Material 可点击工具提示

javascript - react : How to setState in child component from parent component?

javascript - Coldfusion Ajax 多文件上传 - CFFile 覆盖 ServerFile

javascript - CF推送错误: An application could not be detected by any available buildpack

node.js - node.js 中的用户管理系统

javascript - React Router 和导航按钮

reactjs - 无法在 react 三纤维中使用 Canvas 的 PixelRatio

javascript - 如何将函数参数值作为键传递给 JSON 对象?