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

Cannot find module USB #1

Open
amunizp opened this issue Dec 19, 2020 · 4 comments
Open

Cannot find module USB #1

amunizp opened this issue Dec 19, 2020 · 4 comments

Comments

@amunizp
Copy link

amunizp commented Dec 19, 2020

I run keyboard.js expecting the programme to run on command line waiting for keystrokes.

$ node keyboard.js
internal/modules/cjs/loader.js:638
throw err;
^

Error: Cannot find module 'usb'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/andres/tenx_usb_missile_launcher/tenx_driver.js:32:11)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)

@amunizp
Copy link
Author

amunizp commented Dec 19, 2020

OK so sorry, I read the instructions again. Now stuck on keypress.
$ npm install usb
$ npm install -g npm
$ npm install keypress.js
npm WARN saveError ENOENT: no such file or directory, open '/home/andres/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/andres/package.json'
npm WARN andres No description
npm WARN andres No repository field.
npm WARN andres No README data
npm WARN andres No license field.

  • [email protected]
    updated 1 package and audited 1 package in 1.011s
    found 0 vulnerabilities

$ node keyboard.js
internal/modules/cjs/loader.js:638
throw err;
^

Error: Cannot find module 'keypress'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/andres/tenx_usb_missile_launcher/keyboard.js:9:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)

@amunizp
Copy link
Author

amunizp commented Dec 19, 2020

OK deleted modules folder and the "node_modules_old2.json " file.

$ npm install usb

> [email protected] install /home/andres/tenx_usb_missile_launcher/node_modules/usb
> prebuild-install --verbose || node-gyp rebuild

prebuild-install info begin Prebuild-install version 5.3.6
prebuild-install info looking for cached prebuild @ /home/andres/.npm/_prebuilds/405966-usb-v1.6.3-node-v64-linux-x64.tar.gz
prebuild-install info found cached prebuild 
prebuild-install info unpacking @ /home/andres/.npm/_prebuilds/405966-usb-v1.6.3-node-v64-linux-x64.tar.gz
prebuild-install info unpack resolved to /home/andres/tenx_usb_missile_launcher/node_modules/usb/build/Release/usb_bindings.node
prebuild-install info unpack required /home/andres/tenx_usb_missile_launcher/node_modules/usb/build/Release/usb_bindings.node successfully
prebuild-install info install Successfully installed prebuilt binary!
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.

+ [email protected]
added 63 packages from 46 contributors and audited 63 packages in 2.286s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


$ npm install keypress
npm WARN [email protected] No repository field.

+ [email protected]
added 1 package from 1 contributor and audited 64 packages in 0.808s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

$ node keyboard.js 
/home/andres/tenx_usb_missile_launcher/node_modules/usb/usb.js:38
	this.__open()
	     ^

Error: LIBUSB_ERROR_ACCESS
    at Device.usb.Device.open (/home/andres/tenx_usb_missile_launcher/node_modules/usb/usb.js:38:7)
    at TenxDriver.open (/home/andres/tenx_usb_missile_launcher/tenx_driver.js:55:17)
    at Object.<anonymous> (/home/andres/tenx_usb_missile_launcher/keyboard.js:17:6)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)

Sorry is turning out to be a bit of an addition to the readme documentation. It seems it needs to be an admin. Still problem with cursor. But should help any novice like me that comes across this.

$ sudo node keyboard.js 
TENX ROCKET LAUNCHER DEMO
Press Cursor Keys to move camera
Press f to Fire
Press q to quit
got "keypress character" f
got "keypress character" f
got "keypress character" f
got "keypress" up
timers.js:390
    throw new ERR_INVALID_CALLBACK();
    ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at setTimeout (timers.js:390:11)
    at ReadStream.<anonymous> (/home/andres/tenx_usb_missile_launcher/keyboard.js:70:26)
    at ReadStream.emit (events.js:198:13)
    at emitKey (/home/andres/tenx_usb_missile_launcher/node_modules/keypress/index.js:406:12)
    at ReadStream.onData (/home/andres/tenx_usb_missile_launcher/node_modules/keypress/index.js:48:14)
    at ReadStream.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
    at TTY.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

So it shoots but does not understand what moving means. I guess this is because:

Bus 001 Device 014: ID 1130:0202 Tenx Technology, Inc. Rocket Launcher

and it refers to a camera I do not have.

@amunizp
Copy link
Author

amunizp commented Dec 19, 2020

I commented the last line of keyboard.js

// Set a timer to trigger an automatic stop if required
//if (s==1) stop_timer = setTimeout(tenx.stop(), STOP_DELAY_MS);

unsure what it did, but the machine seems to work now.

vale981 added a commit to vale981/tenx_usb_missile_launcher that referenced this issue Dec 19, 2020
@amunizp
Copy link
Author

amunizp commented Dec 19, 2020

I can confirm the above fix, fixes the problem.

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