Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught SyntaxError: The requested module '.../@thiagoelg_node-printer.js?v=e75f09bd' does not provide an export named 'default' #69

Open
gaboroa14 opened this issue May 9, 2023 · 0 comments

Comments

@gaboroa14
Copy link

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?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant