5

我目前正在开发一个电子应用程序,它有时可以将 HTML 文件转换为 PDF 文件。为此,我使用了html-pdf基于phantomjs.

当应用程序未打包但在asar下时,它运行良好,因为无法生成子进程,所以存在未捕获的异常。html-pdf

堆栈错误

internal/child_process.js:302 Uncaught Error: spawn ENOTDIR

exports._errnoException @ util.js:890
ChildProcess.spawn @ internal/child_process.js:302
exports.spawn @ child_process.js:379
PdfExec @ /Users/graphfx/html2pdf/html2pdf.asar/node_modules/html-pdf/lib/…:87
PdfToFile @ /Users/graphfx/html2pdf/html2pdf.asar/node_modules/html-pdf/lib/…:83
convert @ index.html:35
onclick @ index.html:19

我想这是由于节点 API 的asar 限制,但由于 Windows 上的260 个字符路径长度限制,我真的需要将我的应用程序打包到asar中。

我也尝试 --unpack-dir 'node_modules'在构建asar包时使用该选项,但问题仍然存在。

重现错误

git clone https://github.com/Graphfx/html2pdf
cd html2pdf
npm install
npm run asar-pack
npm run start-asar

有人知道如何解决这个问题吗?

4

0 回答 0