usb.on is not a function
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Quiet
- Tech stack
- nodejs
- Domain
- embedded-iot
Research direction
Start at node_modules/escpos-usb/index.js line 52, where the USB constructor calls usb.on, and compare that entry point with the Node v18.15.0 dependency setup in the report. Reproduce the provided index.js example and trace why usb lacks on; done means the constructor no longer throws this error and the printer example can proceed to device.open().
Written by the indexing model from the issue text.
Description
Node v18.15.0
"dependencies": {
"escpos": "^3.0.0-alpha.6",
"escpos-usb": "^3.0.0-alpha.4"
}
Code:
const escpos = require('escpos');
escpos.USB = require('escpos-usb');
const device = new escpos.USB(0x2BDF, 0x0280);
const printer = new escpos.Printer(device);
device.open(function (error) {
if (error) {
console.error('Error opening USB device:', error);
return;
}
printer
.font('a')
.align('ct')
.style('bu')
.size(1, 1)
.text('Your Store Name')
.text('----------------')
.align('lt')
.text('Item 1 $10.00')
.text('Item 2 $7.50')
.text('----------------')
.align('rt')
.text('Total: $17.50')
.cut()
.close();
});
Error:
C:\Users\juan\Desktop\test-printer\node_modules\escpos-usb\index.js:52
usb.on('detach', function(device){
^
TypeError: usb.on is not a function
at new USB (C:\Users\x\Desktop\test-printer\node_modules\escpos-usb\index.js:52:7)
at Object. (C:\Users\x\Desktop\test-printer\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 443
- PR merge metrics
- No merged PRs in 30d
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lsongdev/node-escpos
-
[BUG]:Openbug
Difficulty 4/5 3-5 days Newbie friendliness 15/100
lsongdev/node-escpos#447 ·
-
[BUG]: AJCBOSEOpenbug
Difficulty 5/5 Over a week Newbie friendliness 10/100
lsongdev/node-escpos#446 ·
-
Capt BilalOpen
Difficulty 5/5 Over a week Newbie friendliness 1/100
lsongdev/node-escpos#443 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
lsongdev/node-escpos#442 · 2 reactions ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 38/100
lsongdev/node-escpos#441 · 5 comments · 1 reaction ·
All issues in lsongdev/node-escpos
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
StabilityNexus/Fate-EVM-Frontend#153 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
code-yeongyu/oh-my-openagent#9039 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Tencent/teamai-cli#862 ·
Maintainers usually reply within 1 day
-
bug good first issue hacktoberfest redis
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
libredb/libredb-studio#1164 ·
Maintainers usually reply within 1 day
-
flake
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day