Nextjs with socket.io Work in local but not in Render

The dependencies is below:

 "dependencies": {
    "@types/socket.io": "^3.0.2",
    "@types/styled-components": "^5.1.25",
    "next": "12.2.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "recharts": "^2.1.12",
    "socket.io": "^4.5.1",
    "socket.io-client": "^4.5.1",
    "styled-components": "^5.3.5"
  },
  "devDependencies": {
    "@types/node": "18.0.4",
    "@types/react": "18.0.15",
    "@types/react-dom": "18.0.6",
    "eslint": "8.19.0",
    "eslint-config-next": "12.2.2",
    "typescript": "4.7.4"
  }

The error in deployment is as below:

Jul 15 12:00:28 PM  ./pages/api/message.ts:3:24
Jul 15 12:00:28 PM  Type error: Cannot find module 'Socket.IO' or its corresponding type declarations.
Jul 15 12:00:28 PM  
Jul 15 12:00:28 PM    1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
Jul 15 12:00:28 PM    2 | import type { NextApiRequest, NextApiResponse } from "next";
Jul 15 12:00:28 PM  > 3 | import { Server } from "Socket.IO";
Jul 15 12:00:28 PM      |                        ^
Jul 15 12:00:28 PM    4 | import { DefaultEventsMap } from "socket.io/dist/typed-events";
Jul 15 12:00:28 PM    5 | import { IMessageData } from "../../interfaces";
Jul 15 12:00:28 PM    6 | let message: IMessageData[] = [];
Jul 15 12:00:28 PM  

Hey there,
Looking at your most recent deploy it looks like you’ve got this figured out now,

Let me know?

Regards,

John B

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.