Allow to use it on Node.js environment without manipulating global scope.
See original GitHub issueAs pointed out by @holywyvern - currently it’s required to populate the global
scope in order to get the JavaScript client running on Node.js environment.
It would be better to provide a way to support Node.js without messing up with the global
scope.
Something like:
import { Client } from "colyseus.js";
const Storage = require("dom-storage");
const WebSocket = require("uws");
const client = new Client("endpoint", {
storage: new Storage(null, { strict: true }),
ws: WebSocket
});
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Using Global Variables in Node.js - Stack Abuse
To set up a global variable, we need to create it on the global object. The global object is what gives us the...
Read more >What Are Node JS Global Variables - KnowledgeHut
Global variables are variables that can be declared with a value, and which can be accessed anywhere in a program. The scope of...
Read more >How to use global variable in node.js? - Stack Overflow
Most people advise against using global variables. If you want the same logger class in different modules you can do this. logger.js
Read more >Global objects | Node.js v19.3.0 Documentation
These objects are available in all modules. The following variables may appear to be global but are not. They exist only in the...
Read more >What is globalThis, and why should you start using it?
In Node.js, you can access the global object using the global ... Keep in mind that the top-level scope in Node.js is not...
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 FreeTop 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
Top GitHub Comments
As of 0.9.16, this client now works on Node.js environment out of the box, you just need to include
ws
as a dependency in your project. 🙌Would this be the same case for
React-Native
andwindow.localStorage
?