Currently using node-printer in a React Tauri Typescript project, I'm doing the following:
import { printDirect } from "@thiagoelg/node-printer";
//...
export const printTicket = (ticket: any) => {
printDirect({
data: ticket,
printer: "XP58",
type: "RAW",
options: {},
success: function (jobID) {
console.log("sent to printer with ID: " + jobID);
},
error: function (err) {
console.log(err);
},
});
};
At first I got an error about dirname not being defined. I fixed it by adding these three lines to the printer.js:
import * as url from 'url'; //added to fix dirname error
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
var printer_helper = {},
fs = require("fs"),
child_process = require("child_process"),
os = require("os"),
path = require("path"),
binding_path = path.resolve(__dirname, './node_printer.node'),
printer_helper;
Afterwards, I started getting this error:
Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@thiagoelg_node-printer.js?v=e75f09bd' does not provide an export named 'default' (at index.ts:1:1)
Any idea as to how to fix it? Or should I stick with Electron instead of Tauri?
Currently using node-printer in a React Tauri Typescript project, I'm doing the following:
At first I got an error about dirname not being defined. I fixed it by adding these three lines to the printer.js:
Afterwards, I started getting this error:
Any idea as to how to fix it? Or should I stick with Electron instead of Tauri?
Thanks in advance!