4

I want to create a React application and I want to use a typescript in this application, at first I went to the React website in order to create an application using typescript and I found that I had to put this instruction in the terminal first:

npx create-react-app my-app --template typescript

And when it finished installing, I put it in the terminal:

npm start

But I got this error:

It looks like you're trying to use TypeScript but do not have typescript installed

I opened the terminal and wrote this instruction:

npm install

then i run the app:

npm start 

But the error is still there

How can I solve the problem?

3 Answers 3

6

I solved my problem with the following instruction:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

or

yarn add typescript @types/node @types/react @types/react-dom @types/jest
1
  • 1
    Make sure you check what version of react you are using in your package.json. I received the "It looks like.." error when attempting to add typescript to a React17 project. I had to pin my @types to version 17. E.g. : npm install --save-dev typescript @types/react@17.0.0 @types/node@17.0.0 @types/react-dom@17.0.0
    – AM_FM
    Jul 8, 2022 at 19:30
1

have you tried

npm install -g typescript

yes i tryed but still with error

Have you tried

npm run start
0
0

Consider upgrading Next.js 11 to 12 or to latest version. Also, you need to upgrade types to latest for react and react-dom. Here is a brief documentation about that:

https://nextjs.org/docs/upgrading#upgrade-nextjs-version-to-12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.