Troubleshooting: node_modules/@types/react/index.d.ts – error TS2717


If you encoutner the captioned error when building a react app using typescript, you are not alone, There are bunch of solutions discussed on the internet:

However, none of them worked for me. Finally I found the approach below works:

In the package.json, add below code:

"resolutions": {
  "@types/react": "^16.14.3"  <-- replace the version as you see fit
}

In tsconfig.json, at the end of the file, add below code

 "skipLibCheck": true

Note that if you have multiple project in a root node project, for instance, if you are using Capacitor to add Android, iOS and Electron platforms, you might do so for all the package.json and tsconfig.json files.

Rebuild the project and rerun your apps. Happy coding!

Leave a comment