Error: Required TypeScript & Types packages, despite being installed
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64
Binaries:
Node: 16.13.2
npm: 8.1.2
Yarn: 1.22.18
pnpm: N/A
Relevant packages:
next: 12.1.6-canary.2
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
After running yarn create next-app next-tailwind-typescript-starter --example with-typescript
then yarn build
, I get the error
Please install typescript, @types/react, and @types/node by running:
yarn add --dev typescript @types/react @types/node
My package.json
{
"private": true,
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"type-check": "tsc"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.67.0",
"@types/mongodb": "^4.0.7",
"dotenv": "^16.0.0",
"formidable": "^3.2.1",
"mongodb": "^4.5.0",
"next": "^12.1.6-canary.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
"uniqid": "^5.4.0"
},
"devDependencies": {
"@types/node": "^17.0.24",
"@types/react": "=18.0.1",
"@types/react-dom": "^17.0.1",
"postcss-preset-env": "^7.4.3",
"tailwindcss": "^3.0.23",
"typescript": "^4.6.3"
},
"version": "1.0.0"
}
My tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
This error was mentioned in #36085, #36103, and #36103. I have attempted to change the Next
version to the most recent canary as well as the specified 12.1.5-canary.6
. Additionally, I have attempted to downgrade @types/react
to version 18.0.1
.
Expected Behavior
next build
should not result in any errors and should deploy successfully.
To Reproduce
Run yarn create next-app next-tailwind-typescript-starter --example with-typescript
and yarn add --dev @types/react @types/react-dom @types/node
. Attempt to build (specifically on Vercel in my case) with next build
.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Next.js TypeScript Error: You do not have the required ...
Solved by updating Next.js and React. Updating next.js npm install next@latest. Updating react version in the next.js app:
Read more >it looks like you're trying to use typescript but do not have ...
It looks like you're trying to use TypeScript but do not have the required package (s) installed. Please install @types/react by running: npm...
Read more >@rollup/plugin-typescript - npm
This plugin requires an LTS Node version (v14.0.0+) and Rollup v2.14.0+. This plugin also requires at least TypeScript 3.7. Install. Using npm:.
Read more >A Complete Guide to Using TypeScript in Node.js - Better Stack
We need to set up a configuration file ( tsconfig.json ) for our project before we can start compiling our source files. If...
Read more >How to Upgrade to TypeScript Without Anybody Noticing
So the next step is to start getting rid of incorrect errors and improving Typescript's knowledge of the code. Here's the commit. Install...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seems like there is a bug in some @types/react version. The issue was solved for me by simply updating the @types/react version
In case of npm, do this,
npm install --save-dev @types/react@18.0.1
And for yarn, do
yarn add @types/react@18.0.1
Same issue, blocking vercel deploys. Moving everything out of devDependencies reduces the failure down to:
Edit: solved with violence. Blew up my package-lock and regenerated it.