Open
Description
Description of the bug
\node_modules\escpos-usb\index.js:53
usb.on('detach', function(device){
^
TypeError: usb.on is not a function
at new USB (D:\GolandProjects\testprint\usb_printer_project\usb_printer_project_nodejs\node_modules\escpos-usb\index.js:53:7)
at Object.<anonymous> (D:\GolandProjects\testprint\usb_printer_project\usb_printer_project_nodejs\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1565:14)
at Object..js (node:internal/modules/cjs/loader:1708:10)
at Module.load (node:internal/modules/cjs/loader:1318:32)
at Function._load (node:internal/modules/cjs/loader:1128:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49
Node.js v22.12.0
"escpos": "^3.0.0-alpha.6",
"escpos-usb": "^3.0.0-alpha.4"
Steps To Reproduce
直接使用示例
npm init -y
npm install escpos escpos-usb
node index.js
const escpos = require("escpos");
// install escpos-usb adapter module manually
escpos.USB = require("escpos-usb");
// Select the adapter based on your printer type
const device = new escpos.USB();
// const device = new escpos.Network('localhost');
// const device = new escpos.Serial('/dev/usb/lp0');
const options = { encoding: "GB18030" /* default */ };
// encoding is optional
const printer = new escpos.Printer(device, options);
device.open(function (error) {
printer
.font("a")
.align("ct")
.style("bu")
.size(1, 1)
.text("The quick brown fox jumps over the lazy dog")
.text("敏捷的棕色狐狸跳过懒狗")
.barcode("1234567", "EAN8")
.table(["One", "Two", "Three"])
.tableCustom(
[
{ text: "Left", align: "LEFT", width: 0.33, style: "B" },
{ text: "Center", align: "CENTER", width: 0.33 },
{ text: "Right", align: "RIGHT", width: 0.33 },
],
{ encoding: "cp857", size: [1, 1] } // Optional
)
.qrimage("https://github.com/song940/node-escpos", function (err) {
this.cut();
this.close();
});
});
Additional Information
No response