Unable to require node-hid in Travis CI
See original GitHub issueWhen requiring node-hid in Travis-CI I get this error “cannot initialize hidapi (hid_init failed)”.
I am unable to run unit tests on modules that use node-hid on Travis-CI because this error is thrown when node-hid is required. I have tried to stub out the module in my tests without any luck. I have traced this to https://github.com/node-hid/node-hid/blob/master/src/HID.cc#L583. This code is being run when the module is required and I think this should be done when the HID instance is created.
const HID = require('node-hid'); // Is thrown her.
const device = new HID.HID(path); // Should be thrown her.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Do not execute code on `require`. · Issue #226 · node-hid/node-hid ...
Node -hid is used in one particular code path in my application yet I can't run any of my tests in Docker or...
Read more >Building a JavaScript and Node.js project - Travis CI Docs
This guide covers build environment and configuration topics specific to JavaScript and Node.js projects. Please make sure to read our Tutorial and general ......
Read more >Travis CI: file from node module not found - Stack Overflow
The simplest way to get out of this situation is $ git add --force node_modules/mocha.css node_modules/mocha.js $ git commit -m "Add the ...
Read more >node-hid - UNPKG
The CDN for node-hid. ... Build Status](https://travis-ci.org/libusb/hidapi.svg?branch=master)](https:// ... It requires kernel version at least 2.6.39.
Read more >binance-chain-javascript-sdk-remove-node-hid - npm package
Unable to verify the project's public source code repository. Advisor · JavaScript packages · binance-chain-javascript-sdk-remove-node ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I believe this has been fixed in the latest release. We’re currently doing builds in Travis too. Thanks for your patience.
Thanks, that does work.
Only because mockery is so overly aggressive when it does it’s mocking.
You can get node-hid to install on travice by adding this to travis.yml.
I still think that node-hid should not start executing this code when the module is required.