-
-
Notifications
You must be signed in to change notification settings - Fork 426
usb.on is not a function #428
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
Comments
maybe you can try, usb module version to 1 |
pnpm i usb@1.x |
npm install -S usb@1.8.0 |
You can also run apply this Add this to
Then run |
This worked for me !!
|
Hi, im fixed this using the latest version of usb. then use Zadig driver. |
#429 This was merged and fixed |
I use latest package for escpos-usb, but the error persist I try use directy github repository and branch on my package.json, but cannot use them because typescript code isn't transpiled. any suggestion for it? |
I see that the npm registry was updated 4 years ago and the same with GH registry, so first don't use the npm and GH package. You can try to install from the repo directly. And then build it with |
I'll try to push a GH action to automatically deploy and compile the package. |
Maybe is necessary update version on package.json in ecspos-usb package |
is this project open to pr for update usage of node-usb to latest versions? on version 3 it has broken the api on the listener .on(); |
@clopezpro I think that you can also do the following:
so you don't lose the detach event. Check this commit from a newer version: https://github.com/lsongdev/node-escpos/pull/429/files |
Bro, how can I use the last version in which this is corrected, at the moment run npm i escpos-usb and the version with the USB.on error is installed |
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;
}
});
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
The text was updated successfully, but these errors were encountered: