2

When I try to deploy my app on Vercel, I get the following error:

src/App.tsx(5,22): error TS2307: Cannot find module './components/chat/ChatRoom' or its corresponding type declarations. Error: Command "npm run build" exited with 2

However, the import works in a local dev environment, and when I build the project locally it works as well.

The component the error is about The import the error complains about

I'm really lost as to what could be the problem. The capitalisation looks fine to me, and everything works fine apart from the building on Vercel.

I've tried to rename the component and update the imports, but that doesn't do anything. I'm lost.

1
  • 1
    It'd be helpful to see your Vercel deploy/build logs. Are you getting type errors in your IDE ? What IDE are you using? Commented Nov 16, 2022 at 16:18

2 Answers 2

0

Is this a Next.js project? A quick and dirty solution if you just need to get it deployed would be to turn off typescript typechecking on deploy by setting in your next.config:

typescript: {
  ignoreBuildErrors: true,
},

Probably not what you're looking for tho...

Sign up to request clarification or add additional context in comments.

Comments

0

Just add this in ./tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    //this Line
    "strict": false,
    //this Line
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.