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

ReferenceError: require is not defined #69

Closed
micrology opened this issue May 22, 2021 — with Huly for GitHub · 2 comments
Closed

ReferenceError: require is not defined #69

micrology opened this issue May 22, 2021 — with Huly for GitHub · 2 comments
Assignees
Labels
bug Something isn't working

Comments

Copy link

micrology commented May 22, 2021

Bug Running

HOST=localhost PORT=1234 npx y-websocket-server

yields

ReferenceError: require is not defined

To reproduce:

npm install y-websocket

(installs 1.3.14) Then

HOST=localhost PORT=1234 npx y-websocket-server

which generates:

file:///xxxxxxxx/node_modules/y-websocket/bin/server.js:6
const WebSocket = require('ws')
                  ^

ReferenceError: require is not defined
    at file:///xxxxxxx/node_modules/y-websocket/bin/server.js:6:19
    at ModuleJob.run (internal/modules/esm/module_job.js:146:23)
    at async Loader.import (internal/modules/esm/loader.js:165:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)

Expected behavior a notice to say that y-webserver is running on port 1234

Environment Information node v14.15.1 y-webserver 1.3.14

y-webserver Version 1.3..11 didn't have this problem.

Huly®: YJS-504

@micrology micrology added the bug Something isn't working label May 22, 2021
@istvank
Copy link
Contributor

istvank commented May 23, 2021

I guess this is related to eba986d

If I remove the "type": "module", it works again.

@dmonad dmonad closed this as completed in 0a744c3 May 23, 2021
@dmonad
Copy link
Member

dmonad commented May 23, 2021

I'm sorry for that. I fixed another bug with that but I broke the server by doing that. I will wait for the next major release to rewrite the server as an ESM module.

I'll shortly release a new version with a fix.

billiegoose added a commit to stoplightio/y-websocket that referenced this issue Sep 29, 2021
* Update README.md

* fix: Memory leak with old versions of yjs

Versions of yjs prior to `13.4.6` did not emit a `"destroy"` event when a doc is destroyed, meaning that doc's in the websocket servers memory are not correctly cleaned up.

* Update package-lock.json

* Extendable messageHanlers

* update deps

* 1.3.10

* remove node types from client code

* 1.3.11

* lint

* Add info about y-websocket-server to quick-start

* add on exit handler for Node.js environments

* 1.3.14

* Fix a `peerDependencies` typo in `package.json`

* fix typo

* Remove dependency on window - fixes yjs#65

* 1.3.12

* use condititional exports of dependencies

* 1.3.13

* set correct module type

* 1.3.14

* fix yjs#69 by reverting esm change

* 1.3.15

* Fix beforeunload memory leak

* 1.3.16

Co-authored-by: Kevin Jahns <[email protected]>
Co-authored-by: Tom Moor <[email protected]>
Co-authored-by: Kevin Jahns <[email protected]>
Co-authored-by: Hans Pagel <[email protected]>
Co-authored-by: Thomas Parisot <[email protected]>
Co-authored-by: Nemanja Tosic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants