skip to Main Content

I am receiving an error while trying to use Typescript with my existing expo project.

While following the docs, I created a tsconfig.json file in the project root.

When running expo start, I am prompted to install the typescript dependencies. However, after these are successfully installed (tick message appears in console: √ Installed typescript@~4.3.5, @types/react@~17.0.21, @types/react-native@~0.67.6), I receive the following error:

It looks like you're trying to use TypeScript but don't have the required dependencies installed.

Please install @types/react by running:

yarn add --dev @types/react@~17.0.21

If you're not using TypeScript, please remove the TypeScript files from your project and delete the tsconfig.json.

error Command failed with exit code 1.

After following the instructions and running the yarn add .... command, I keep seeing the same error message.

I have tried deleting the node_modules folder and package-lock.json file to no avail. I have also tried following this answer.
Any assistance would be appreciated, thank you.

7

Answers


  1. Seems to be a bug. It works if I install @types/react on the specific version that Expo requests (17.0.21).

    yarn add --dev @types/[email protected]
    
    Login or Signup to reply.
  2. I don’t know which of the following worked, but I ran the following commands and the problem went away.

    • sudo npm install -g expo-cli

    • sudo npm install -g @types/react

    • sudo npm install -g @types/react-native

    • sudo npm install -g typescript

    Login or Signup to reply.
  3. yarn add expo-cli
    

    solved for me.

    Login or Signup to reply.
  4. Just re-install expo-cli npm install -g expo-cli.

    Login or Signup to reply.
  5. I had the same issue. I resolved it by :

    1- delete the node_modules.

    2- update expo to the latest version using npm i -g expo-cli

    hope this will help someone

    Login or Signup to reply.
  6. if you installed @types/react remove that from your dev dependencies

    Login or Signup to reply.
  7. I solved it running YARN_CHECKSUM_BEHAVIOR=update yarn

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search