Skip to content

server not launching when persistence is used #2

@dignakov

Description

@dignakov

Describe the bug
starting the server with persistence seems to not work

To Reproduce

  1. in a terminal (dbDir exists)
  2. HOST=localhost PORT=1234 YPERSISTENCE=./dbDir npx @y/websocket-server
  3. results in an error:
Persisting documents to "./dbDir"
file:///home/me/.npm/_npx/17f6bbf3c399f7d5/node_modules/@y/websocket-server/src/utils.js:33
  const LeveldbPersistence = require('y-leveldb').LeveldbPersistence
                             ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/me/.npm/_npx/17f6bbf3c399f7d5/node_modules/@y/websocket-server/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///home/me/.npm/_npx/17f6bbf3c399f7d5/node_modules/@y/websocket-server/src/utils.js:33:30
    at ModuleJob.run (node:internal/modules/esm/module_job:268:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)

Node.js v23.1.0

Without ypersistence it runs fine.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions