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

Using node-irc in the client side with React #535

Open
enriquemorenotent opened this issue Jun 8, 2018 · 2 comments
Open

Using node-irc in the client side with React #535

enriquemorenotent opened this issue Jun 8, 2018 · 2 comments

Comments

@enriquemorenotent
Copy link

I am trying to build a IRC client using React, and I wanted to use this package. While running on the command line, a simple command like this seemed to work great.

new irc.Client( 'chat.freenode.net', 'Helloworld', { channels: ["#test"] })

But when I put the code inside my react app I meet this error in the console:

irc.js:796 Uncaught TypeError: net.createConnection is not a function
	at Client../node_modules/irc/lib/irc.js.Client.connect (irc.js:796)
	at new Client (irc.js:107)
	at reducer (reducer.js:50)
	at dispatch (redux.js:213)
	at redux-logger.js:1
	at Object.dispatch (index.js:11)
	at ChannelView.connectToServer (ChannelView.js:9)
	at onClick (ChannelView.js:24)
	at HTMLUnknownElement.callCallback (react-dom.development.js:100)
	at Object.invokeGuardedCallbackDev (react-dom.development.js:138)
	at Object.invokeGuardedCallback (react-dom.development.js:187)
	at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:201)
	at executeDispatch (react-dom.development.js:461)
	at executeDispatchesInOrder (react-dom.development.js:483)
	at executeDispatchesAndRelease (react-dom.development.js:581)
	at executeDispatchesAndReleaseTopLevel (react-dom.development.js:592)
	at forEachAccumulated (react-dom.development.js:562)
	at runEventsInBatch (react-dom.development.js:723)
	at runExtractedEventsInBatch (react-dom.development.js:732)
	at handleTopLevel (react-dom.development.js:4472)
	at batchedUpdates$1 (react-dom.development.js:16537)
	at batchedUpdates (react-dom.development.js:2131)
	at dispatchEvent (react-dom.development.js:4551)
	at interactiveUpdates$1 (react-dom.development.js:16592)
	at interactiveUpdates (react-dom.development.js:2150)
	at dispatchInteractiveEvent (react-dom.development.js:4528)

Why am I meeting this error on the browser with the same code? Is node-irc not suited to run on the browser? Do I need to create my own API to communicate with it?

@timwangdev
Copy link

timwangdev commented Jun 28, 2018

Is node-irc not suited to run on the browser?

No, it requires node apis.

@tmfksoft
Copy link

A late response, I'm looking into doing similar.
In this case you'd need a NodeJS backend with a WebSocket.

Alternatively if you're using Electron you could either use preloads or give direct access to NodeJS within the BrowserWindow.

The net library that this library uses is a NodeJS Module thus doesn't exist within a browser context.

Hope this answers anyones questions about this in future, this also will apply to Angular or any other web based frontend.

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

3 participants