I have a logitech gaming steering wheel that I would like to send signals over the web to another peer. I am using PeerJS to establish this connection. When I run the code in a nodejs environment offline I am able to establish a connection with the steering wheel and extract signals.
However, when I tried to display the signals on the HTML console I would get an error that would say "require is not defined". To get rid of the "require is not defined" error, I used browserify to be able to use the logitech-g29 module on the web but it gave me the new error with "exists is not a function" in the browserify created js file.
How can I avoid this Uncaught TypeError when I try to establish a connection with the steering wheel? This error is called in the bundle.js file that's created from browserify.
Command Line code with browserify
browserify -r logitech-g29 -o bundle.js
sender.html
<script src="https://unpkg.com/peerjs@1.3.1/dist/peerjs.min.js"></script>
<script type="text/javascript" src="bundle.js"></script>
<script type="text/javascript" src="main.js"></script>
main.js
(function () {
const logitech = require('logitech-g29');
var lastPeerId = null;
var peer = null; // own peer object
var conn = null;
var recvIdInput = document.getElementById("receiver-id");
var status = document.getElementById("status");
var message = document.getElementById("message");
var sendMessageBox = document.getElementById("sendMessageBox");
var sendButton = document.getElementById("sendButton");
var clearMsgsButton = document.getElementById("clearMsgsButton");
var connectButton = document.getElementById("connect-button");
function steeringWheel(){
const options = {
autocenter: true,
range: 270
}
// This is where occurs below
logitech.connect(options, function(err) {
console.log('Ready')
})
}