我正在尝试让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
无效。出现其他类型的错误。
我做错了什么?
1条答案
按热度按时间6ljaweal1#
这个问题已经通过使用
[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)
而不是[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)
得到了修复,但由于我的Electron应用程序使用了导入样式语句,因此原始原因仍然未知。