I'm trying to use the websockets provided with trpc for a live chat. But when I follow the documentation and create the context as provided:
import {NodeHTTPCreateContextFnOptions} from "@trpc/server/dist/adapters/node-http";
import { IncomingMessage } from "http";
import ws from "ws";
export async function createContext(opts:
| CreateExpressContextOptions
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>) {
const { req, res } = opts;
const u = deserializeUser(<CreateExpressContextOptions>{ req, res });
return createInnerTRPCContext({
req: (await u).req,
res: (await u).res,
user: (await u).user,
});
}
I get the following error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/adapters/ws' is not defined by "exports" in C:\Users\Schla\Documents\Semester 6\fwe-project\backend\node_modules@trpc\server\package.json
Does anyone have an idea why this happens?