【发布时间】:2020-02-26 05:31:42
【问题描述】:
我正在使用 Electron 和 ReactJS 和 typescript 构建跨平台桌面应用程序。所以有一个像下面这样的功能。该功能正在调用按钮单击,它应该在连接的默认打印机中打印文本。这是处理打印操作的第三方库。但问题是当我使用此功能时,我的应用程序无法加载。它崩溃了。
function printcheck() {
const printer = require('electron-print');
app.on('ready', function() {
printer.print("Text sent to printer.");
});
}
显示的错误是 TypeError: fs.existsSync is not a function 并且错误指向 node_modules/electron/index.js:7。我也使用过许多其他第三方打印库。此时所有人都崩溃了。
function getElectronPath () {
> 7 | if (fs.existsSync(pathFile)) {
任何帮助将不胜感激。
【问题讨论】:
-
提供您使用的 Electron 版本以及崩溃的最小示例(例如使用electronjs.org/fiddle)将有助于调试错误。
标签: reactjs typescript electron