peers / peerjs-server

Server for PeerJS
https://peerjs.com
MIT License
4.26k stars 1.08k forks source link

TypeError: (0 , $cl6Iw$ws.WebSocketServer) is not a constructor #409

Closed antonio-couto closed 1 year ago

antonio-couto commented 1 year ago

I'm having an issue:

code:

import { PeerServer} from 'peer';
const peerServer = PeerServer({
    port: 9000,
});

tsconfig.json

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  },
  "files": [
    "peer-test.ts"
  ]
}

trace

PS D:\Source\gitlab\voxage\nodejs\screen-peer> node .\peer-test.js
D:\Source\gitlab\voxage\nodejs\screen-peer\node_modules\peer\dist\index.cjs:273
        this.socketServer = config.createWebSocketServer ? config.createWebSocketServer(options) : new (0, $cl6Iw$ws.WebSocketServer)(options);
                                                                                                   ^

TypeError: (0 , $cl6Iw$ws.WebSocketServer) is not a constructor
    at new $e9ffe6de55430dbc$export$f47674b57e51ee3b (D:\Source\gitlab\voxage\nodejs\screen-peer\node_modules\peer\dist\index.cjs:273:100)     
    at $516a786dc008ff17$export$99152e8d49ca4e7d (D:\Source\gitlab\voxage\nodejs\screen-peer\node_modules\peer\dist\index.cjs:522:17)
    at Function.<anonymous> (D:\Source\gitlab\voxage\nodejs\screen-peer\node_modules\peer\dist\index.cjs:560:55)
    at Function.emit (node:events:539:35)
    at Function.<anonymous> (D:\Source\gitlab\voxage\nodejs\screen-peer\node_modules\express\lib\application.js:245:8)
    at Array.forEach (<anonymous>)
    at Function.use (D:\Source\gitlab\voxage\nodejs\screen-peer\node_modules\express\lib\application.js:224:7)
    at $123f4982a51872b4$export$f99d31af51f48b1e (D:\Source\gitlab\voxage\nodejs\screen-peer\node_modules\peer\dist\index.cjs:583:9)
    at Object.<anonymous> (D:\Source\gitlab\voxage\nodejs\screen-peer\peer-test.js:4:42)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
tysongf commented 1 year ago

I'm having this same issue

jonasgloning commented 1 year ago

Thanks for the report. I can’t reproduce this on my machine.

Maybe:

antonio-couto commented 1 year ago

Now I am using nodejs v20.3.0 and I removed modules and the lock file. Everything is working now. thanks a lot.