Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow to use it on Node.js environment without manipulating global scope.

See original GitHub issue

As 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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

endelcommented, Jan 21, 2019

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. 🙌

cayassocommented, Dec 11, 2018

Would this be the same case for React-Native and window.localStorage?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found