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

Navigator not defined #11

Open
iamchathu opened this issue Jun 3, 2019 · 1 comment
Open

Navigator not defined #11

iamchathu opened this issue Jun 3, 2019 · 1 comment

Comments

@iamchathu
Copy link

When I try to run the example from Node it gives

/webusb/node_modules/webusb-serial/index.js:66
    navigator.usb.requestDevice({filters: self.filters })
    ^

ReferenceError: navigator is not defined
    at new WebUSBSerialPort (/webusb/node_modules/webusb-serial/index.js:66:5)
    at Object.<anonymous> (/webusb/webusb-test.js:5:18)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Seems this library for Browser but when I use it as a browser code require is not defined. Seems example need to updated.

@monteslu
Copy link
Owner

monteslu commented Jun 3, 2019

it is made for browsers, however there is a webusb for node project here: https://github.com/thegecko/webusb

My example is assuming that you're using a bundler such as browserify or webpack to build for browser

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

2 participants