ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.19k stars 115 forks source link

hocuspocus-server fails to launch in local environments via npx #837

Closed dvago closed 1 month ago

dvago commented 2 months ago

Description Follow the documentation from TipTap Docs The npx command to spawn the hocuspocus server fails to work in environments such as macOS/Windows because of a failed import.

Steps to reproduce the bug Steps to reproduce the behavior:

  1. Go to your terminal
  2. Type in npx @hocuspocus/cli --port 1234 or npx @hocuspocus/cli --port 1234 --sqlite
  3. See error message Cannot find package 'yjs' imported from [PATH]/.npm/_npx/a57a221d08bbf04d/node_modules/@hocuspocus/server/dist/hocuspocus-server.esm.js

Expected behavior I would expect the server to pull yjs and other dependencies during the npx execution.

Environment?

janthurau commented 1 month ago

hmm weird, can't reproduce this:

➜  ~ npx @hocuspocus/cli --port 1234
Need to install the following packages:
@hocuspocus/cli@2.13.2
Ok to proceed? (y) yes
npm WARN deprecated npmlog@6.0.2: This package is no longer supported.
npm WARN deprecated are-we-there-yet@3.0.1: This package is no longer supported.
npm WARN deprecated gauge@4.0.4: This package is no longer supported.

  Hocuspocus v2.13.2 running at:

  > HTTP: http://0.0.0.0:1234
  > WebSocket: ws://0.0.0.0:1234

  Extensions:
  - Logger

  Ready.

^C[2024-07-01T18:28:13.840Z] Shut down.

Can you share the full error message, and also your node version?

dvago commented 1 month ago

Hi @janthurau

Apologies for the late reply but I was on holiday and I couldn't provide you with this information earlier.

✗ npx @hocuspocus/cli --port 1234
Need to install the following packages:
@hocuspocus/cli@2.13.5
Ok to proceed? (y) y
node:internal/modules/esm/resolve:844
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
        ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'yjs' imported from /Users/myuser/.npm/_npx/a57a221d08bbf04d/node_modules/@hocuspocus/server/dist/hocuspocus-server.esm.js
    at packageResolve (node:internal/modules/esm/resolve:844:9)
    at moduleResolve (node:internal/modules/esm/resolve:901:20)
    at defaultResolve (node:internal/modules/esm/resolve:1131:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v21.6.0