score:23

Accepted answer

you can add this to your .eslintignore file in the root of your project.

node_modules

create-react-app team will release a new version with that fix also

https://github.com/facebook/create-react-app/pull/8376

score:0

your error message says eslint is looking for typescript because of a setting in the file .eslintrc so try looking in that file for @typescript-eslint/parser and remove it.

score:0

i was removing typescript from a project and i got the same error because i had forgotten a typescript definition somewhere under the src folder... deleting the file fixed the issue.

score:0

in my case, i wanted typescript, but didn't get it installed. this question still helped me figure out my problem which is described below.

i was watching a youtube video, react typescript tutorial that explained how to get started with typescript and react, and the video said to run:

npx create-react-app cra-ts --typescript

this didn't work (but i didn't know it). as soon as i created a hello.ts file, i got the error the op describes.

error: failed to load parser '@typescript-eslint/parser' declared in 'package.json ยป eslint-config-react-app#overrides[0]': cannot find module 'typescript'

the fix was to use the command:

npx create-react-app myappts --template typescript

this used create-react-app@4.0.0 and react-scripts@4.0.0.

protip: if your newly created react app doesn't have a file named app.tsx, then you haven't actually created it correctly.

score:1

most likely, you have this in your .eslintrc:

extends: react-app

it means the following rule is applied:

files: ['**/*.ts?(x)'], 
parser: '@typescript-eslint/parser', 

which probably means you have *.ts/*.tsx files in your root folder. but maybe it's the vscode-eslint. did you try to run yarn lint from the terminal?

score:3

create react app adds eslint config to package.json, so you just have to add eslintignore with node_modules in package.json. a cleaner alternative to creating a separate file .eslintignore

  // package.json
  // ...
  "eslintconfig": {
    "extends": "react-app"
  },
  "eslintignore": [
    "node_modules",
    "build/*"
  ],

score:5

i had the same issue when trying to create a new react app today.

you can try the following steps:

  1. make sure you update your nodejs to the latest version
  2. make sure your folder path is short and does not contain spaces
  3. run: npm install -g create-react-app
  4. run: npm i --save-dev typescript @typescript-eslint/parser
  5. run: create-react-app my-app

Related Query

More Query from same tag