Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint-config-react-app > @typescript-eslint/parser missing typescript? #8745

Closed
peteyycz opened this issue Mar 30, 2020 · 9 comments · May be fixed by #9310
Closed

eslint-config-react-app > @typescript-eslint/parser missing typescript? #8745

peteyycz opened this issue Mar 30, 2020 · 9 comments · May be fixed by #9310

Comments

@peteyycz
Copy link

peteyycz commented Mar 30, 2020

Describe the bug

Running:
npx eslint .
Returns:
Failed to load parser '@typescript-eslint/parser' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript'

Did you try recovering your dependencies?

Tried reinstalling everything, sadly it didn't work.

I've also tried installing typescript as described in the error but it was lacking a tsconfig.json and I also doubt I should have one if this is not a typescript project.

Environment

Environment Info:

  current version of create-react-app: 3.4.0
  running from /Users/peteyycz/.nvm/versions/node/v10.19.0/lib/node_modules/create-react-app

  System:
    OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
  Binaries:
    Node: 10.19.0 - ~/.nvm/versions/node/v10.19.0/bin/node
    Yarn: Not Found
    npm: 6.14.2 - ~/.nvm/versions/node/v10.19.0/bin/npm
  Browsers:
    Chrome: 80.0.3987.149
    Firefox: 74.0
    Safari: 13.1
  npmPackages:
    react: ^16.13.1 => 16.13.1
    react-dom: ^16.13.1 => 16.13.1
    react-scripts: 3.4.1 => 3.4.1
  npmGlobalPackages:
    create-react-app: 3.4.0

Steps to reproduce

(Write your steps here:)

  1. npx create-react-app myapp
  2. cd myapp
  3. npx eslint .

Expected behavior

It should have ran eslint.

Actual behavior

Failed to load parser '@typescript-eslint/parser' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript'

Additional resources

Based on my investigation it might be related to how eslint is now resolving configuration:

https://eslint.org/docs/user-guide/migrating-to-6.0.0#package-loading-simplification
Which I have found here:
standard/semistandard#249

EDIT: although now I think about it it's probably a different issue: their case the plugin was missing but in my case the plugin is found but the plugin is missing typescript as a peerdep.


https://github.com/facebook/create-react-app/blob/master/packages/eslint-config-react-app/package.json#L19

and this optional: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/package.json#L56 is not really optional


Might also be related
eslint/eslint#12376

@obrejla
Copy link

obrejla commented Mar 31, 2020

Hi, I have the same problem.

Started to happen once I updated react and react-dom from 16.10.0 and react-scripts from 3.2.0.

$ npx create-react-app --info
npx: installed 99 in 39.462s

Environment Info:

  current version of create-react-app: 3.4.1
  running from C:\Users\ji663\scoop\persist\nodejs\cache\_npx\15068\node_modules\create-react-app

  System:
    OS: Windows 10 10.0.17134
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  Binaries:
    Node: 13.1.0 - ~\scoop\apps\nodejs\current\node.EXE
    Yarn: 1.19.1 - ~\scoop\apps\yarn\current\Yarn\bin\yarn.CMD
    npm: 6.12.1 - ~\scoop\apps\nodejs\current\npm.CMD
  Browsers:
    Edge: 42.17134.1098.0
    Internet Explorer: 11.0.17134.1
  npmPackages:
    react: ^16.13.1 => 16.13.1
    react-dom: ^16.13.1 => 16.13.1
    react-scripts: 3.4.1 => 3.4.1
  npmGlobalPackages:
    create-react-app: Not Found

@stale
Copy link

stale bot commented Apr 30, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Apr 30, 2020
@alex-benoit
Copy link

you can fix this by adding typescript to your dependencies

npm install typescript --save-dev

@stale stale bot removed the stale label Apr 30, 2020
@Chernavskikh
Copy link

Having a same problem with latest create-react-app version

@Annis-Monadjem
Copy link

having exact same problem:

Kernel: 4.15.0-99-generic x86_64 bits: 64 compiler: gcc v: 7.5.0 Desktop: Xfce 4.14.1
Distro: Linux Mint 19.3 Tricia base: Ubuntu 18.04 bionic

@damien-git
Copy link

I think this is related to #6834 (reported on April 2019).

@tnovau
Copy link

tnovau commented Jun 7, 2020

yarn add -D typescript

@stale
Copy link

stale bot commented Jul 11, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale
Copy link

stale bot commented Jul 18, 2020

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants
@obrejla @peteyycz @damien-git @Annis-Monadjem @alex-benoit @Chernavskikh @tnovau and others