question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

create-next-app --ts not recognising @types/react

See original GitHub issue

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 19.6.0: Thu Jan 13 01:26:33 PST 2022; root:xnu-6153.141.51~3/RELEASE_X86_64 Binaries: Node: 16.13.1 npm: 8.3.0 Yarn: 1.22.15 pnpm: 6.11.0 Relevant packages: next: 12.1.5-canary.6 react: 18.0.0 react-dom: 18.0.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

After running npx create-next-app@latest --ts test-app then cd test-app && npm run dev, I get the following error:


> test-app@0.1.0 dev > next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000 It looks like you’re trying to use TypeScript but do not have the required package(s) installed.

Please install @types/react by running:

yarn add --dev @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).


Running the @types/react installation command doesn’t fix the problem. @types/react version 18.0.2 is listed as a devDependency in the package.json.

Expected Behavior

create-next-app@latest --ts should create a template which works when npm run dev is called.

To Reproduce

npx create-next-app@latest --ts test-app

cd test-app && npm run dev

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:49
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

33reactions
andresmanzcommented, Apr 12, 2022

Downgrading @types/react to 18.0.1 works for me as a workaround. Might be related to https://github.com/facebook/react/issues/24304?

7reactions
JayAcharcommented, Apr 12, 2022

I’ve got it working again by downgrading only the @types/react package. Thanks @andresmanz

"@types/react": "18.0.1"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js is not recognizing '@types/react' - Stack Overflow
I tried running npm install --save-dev @types/react and got no error messages (just a bunch of warnings but I don't think they are...
Read more >
dev @types/react if you are not trying to use typescript, please ...
it looks like you're trying to use typescript but do not have the required package(s) ... create-next-app --ts not recognising @types/react #36085 -...
Read more >
Let's see how to apply and use TypeScript in the Next.js project.
It looks like you're trying to use TypeScript but do not have the required package(s) installed. Please install @types/react and @types/node ...
Read more >
Next.jsで @types/react v18.0.2以降だとビルドが失敗する - Zenn
Please install @types/react by running: npm install --save-dev ... create-next-app --ts not recognising @types/react · Issue #36085 ...
Read more >
Build a Next.js App with React & TypeScript - YouTube
How to build a website with the Next.js React framework using TypeScript.TL;DR: npx create-next-app @latest -- ts ; cd my-app; npm run build; ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found