Please keep in mind that I am VERY new to all of this javascript/node.js style of HTML coding. In the past, all I have ever done with HTML is static/information style pages.
I am trying to create an HTML webpage that will take xmpp related information from a user (server address, port, user JID, password, chat messages, other user JID, etc.) and route it through the node.js server to the xmpp server. Ultimately, what I am trying to do is take the webrtc.io code and extend it to be tied to and interact with users on an XMPP server. In trying to do this, I found the node-xmpp module and "installed" it (npm install) to the node_modules folder within my project working directory.
I then created a very basic index.html file (text input boxes) that takes user information and then calls functions within a javascript file that is included in the index.html file. Within the javascript file, I added the require function/call const xmpp = require('node-xmpp')
, added the var client = new xmpp.Client({[connection settings]});
and then started with some basic stanza handler and other xmpp functions.
When I then "run" the code in the browser, before I even start entering in information, I see that the console is reporting errors. At first they were errors with the xmpp functions I wrote, so I commented everything out to just have the new xmpp.Client({})
line just to see if it would even connect. But then, I would get an error with the cont xmpp = require('node-xmpp')
. That error is
Uncaught ReferenceError: require is not defined (anonymous function)
From my limited understanding of all of this html/javascript/server stuff, I think what is happening is that the client/browser does not know/have access to either the node.js or node-xmpp library.
Is this right? Should I be doing things differently? And are there any good tutorials/documentation out there that covers this?