electron 电子主进程内的pdf.js库

qni6mghb  于 5个月前  发布在  Electron
关注(0)|答案(1)|浏览(73)

我正在尝试让pdf.js lib在我的主Electron进程中工作。

import { getDocument } = require('pdfjs-dist');

字符串
在启动时,我得到以下错误:

require() of ES Module C:\Workspaces\Workspaces\Stellifill\electron\stellifill\node_modules\pdfjs-dist\build\pdf.mjs not supported. Instead change the require of C:\Workspaces\Workspaces\Stellifill\electron\stellifill\node_modules\pdfjs-dist\build\pdf.mjs to a dynamic import() which is available in all CommonJS modules.


我尝试将nodeIntegration参数更改为true,但这不起作用。
尝试index.cjs并将package.json type切换到module无效。出现其他类型的错误。
我做错了什么?

6ljaweal

6ljaweal1#

这个问题已经通过使用[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)而不是[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)得到了修复,但由于我的Electron应用程序使用了导入样式语句,因此原始原因仍然未知。

相关问题