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

Can't configure in Express and Electron node_modules/iconv-lite/lib/index.js #237

Open
TranceDevCode opened this issue Oct 4, 2023 · 0 comments

Comments

@TranceDevCode
Copy link

TranceDevCode commented Oct 4, 2023

Hello, i have a problem with the integration and configuration of node-thermal-printer.

I create a project with VueJS 3 in the front with Electron-builder from Vue Cli, later add Express in backend, everything until here is working good. Later i install the package with yarn add node-thermal-printer and try to configure this in the server.js, i have this configuration, but this return me an error...

server.js

`const express = require('express');
const app = express();
const { ThermalPrinter, PrinterTypes } = require('node-thermal-printer');

app.use(express.json());

app.listen(3005, () => {
console.log('Servidor corriendo en puerto 3000 desde Backend')
});
app.post('/print', (req, res) => {
let printer = new ThermalPrinter({
type: PrinterTypes.EPSON, // Tipo de impresora
interface: 'tcp:https://xxx.xxx.xxx.xxx', // Dirección de la impresora
// Otras configuraciones de la impresora según tus necesidades
});

// Configura el contenido de impresión aquí
printer.alignCenter();
printer.print("Recibo de Compra");
printer.newLine();
printer.text("Producto: Ejemplo");
// Agrega más contenido según tus necesidades

// Ejecuta la impresión
printer.execute();

res.send('Imprimiendo...'); // Envía una respuesta al cliente

});`

This return me the error:

Uncaught TypeError: __webpack_require__(...) is not a function at eval (index.js?e035:144) at Object../node_modules/node-thermal-printer/node_modules/iconv-lite/lib/index.js (chunk-vendors.js:428) at __webpack_require__ (app.js:395) at fn (app.js:615) at eval (core.js?fd4d:2) at Object../node_modules/node-thermal-printer/lib/core.js (chunk-vendors.js:126) at __webpack_require__ (app.js:395) at fn (app.js:615) at eval (node-thermal-printer.js?19fb:1) at Object../node_modules/node-thermal-printer/node-thermal-printer.js (chunk-vendors.js:296)

this is my devDependecies and dependencies:

"dependencies": { "core-js": "^3.8.3", "express": "^4.18.2", "node-thermal-printer": "^4.4.0", "vue": "^3.2.13" }, "devDependencies": { "@babel/core": "^7.12.16", "@babel/eslint-parser": "^7.12.16", "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-service": "~5.0.0", "electron": "^13.0.0", "electron-devtools-installer": "^3.1.0", "eslint": "^7.32.0", "eslint-plugin-vue": "^8.0.3", "vue-cli-plugin-electron-builder": "~2.1.1" },

Node 16.20

Later i try to configure using the electron configuration... this example in the page:

`const express = require('express');
const app = express();
const ThermalPrinter = require("node-thermal-printer").printer;
const PrinterTypes = require("node-thermal-printer").types;
const electron = typeof process !== 'undefined' && process.versions && !!process.versions.electron;

app.use(express.json());

app.listen(3005, () => {
console.log('Servidor corriendo en puerto 3000 desde Backend')
});
app.post('/print', (req, res) => {
let printer = new ThermalPrinter({
type: PrinterTypes.EPSON,
interface: 'printer:My Printer',
driver: require(electron ? 'electron-printer' : 'printer')
});

// Configura el contenido de impresión aquí
printer.alignCenter();
printer.print("Recibo de Compra");
printer.newLine();
printer.text("Producto: Ejemplo");
// Agrega más contenido según tus necesidades

// Ejecuta la impresión
printer.execute();
res.send('Imprimiendo...'); // Envía una respuesta al cliente

});`

and this return me a new errors:

Module not found: Error: Can't resolve 'electron-printer' in 'D:\App\app-vue-express-electron'
Module not found: Error: Can't resolve 'printer' in 'D:\App\app-vue-express-electron'

@TranceDevCode TranceDevCode changed the title Can configure in Express and Electron node_modules/iconv-lite/lib/index.js Can't configure in Express and Electron node_modules/iconv-lite/lib/index.js Oct 4, 2023
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