1

All of a sudden, my Next.js deployment to Vercel stopped working after the latest deploy and started complaining about not having @types/react AND typescript installed.

It looks like you're trying to use TypeScript but do not have the required package(s) installed.
Please install typescript and @types/react by running:

    npm install --save-dev typescript @types/react

If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).

In my project I am using:

  "@types/react": "18.2.15",
  "typescript": "5.1.6"

I did not modify these packages at all in the failed deployment. The only change I made to the dependencies was adding cheerio. I tried rebuilding the package.json as well and that did not get rid of this error.

I came across this old post with almost the same issue. However since it is outdated I decided to open a new question for 2023. The old solution was downgrading the @types/react version but it does not work for me.

How can I get past this blocker? Thanks

1 Answer 1

2

The issue was that I was setting the NODE_ENV secret in production. After removing it, my issues were gone. I did not know Next JS will automatically set this secret when building.

Seems like it should not throw an error if the user accidentally sets it like I did. Or at least throw a helpful error. But nonetheless, my solution was to remove the NODE_ENV secret from the Vercel environment variables.

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

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.