#socket.io and typescript
26 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
What's the error?
That's different code now
when i create new Socket
yes but error is same
when i create Socket
and add option cors
it says that the constructor doesnt exist
"version": "4.7.2",
Hmm... Using the same version and following code works fine for me:
import express from 'express'
import http from 'http'
import { Server } from 'socket.io'
const app = express()
const server = http.createServer(app)
const io = new Server(server, {
cors: {
origin: '*'
}
})
Maybe try it with an http server
can you give me tsconfig
file
@rotund copper
i am using pnpm, can this be problem?
Mostly default:
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
No idea. Try with NPM but I don't really think that should make a difference
Was it the Config?
yes
Alright then