create-next-app --ts not recognising @types/react
See original GitHub issueVerify 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:
- Created a year ago
- Reactions:49
- Comments:17 (6 by maintainers)
Top GitHub Comments
Downgrading @types/react to 18.0.1 works for me as a workaround. Might be related to https://github.com/facebook/react/issues/24304?
I’ve got it working again by downgrading only the
@types/react
package. Thanks @andresmanz