You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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...
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://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)
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'
The text was updated successfully, but these errors were encountered:
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
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://xxx.xxx.xxx.xxx', // Dirección de la impresora
// Otras configuraciones de la impresora según tus necesidades
});
});`
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')
});
});`
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'
The text was updated successfully, but these errors were encountered: