I have sample installation of react-app and I got the following
Error: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc » eslint-config-react-app#overrides[0]': Cannot find module 'typescript'
after running
npm run lint -> eslint .
I don't use typescript in this project. I tried to install it from scratch and got it again. also tried to remove tslint from vscode plugin
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 Show activity on this post.
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. Show activity on this post.
The simplest way to create a basic react app is to run npx create-react-app my-app --template typescript and boom your basic react app will be created but have you ever wondered, can I do that whole process on my own? Well yes, you can. Pre-requisites: Node js and Vs code.
The built-in eslint integration in Webstorm runs correctly per-file on all the files but crashes with the same error on my typedefs file. @Kicu The plugin determines whether you're using Typescript or not by searching for *.ts files. You think you're not using ts while in fact you are.
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
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/*"
],
I had the same issue when trying to create a new react app today.
You can try the following steps:
npm install -g create-react-app
npm i --save-dev typescript @typescript-eslint/parser
create-react-app my-app
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With