facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.65k stars 26.81k forks source link

Failed to load plugin '@typescript-eslint' declared in '.eslintrc » eslint-config-react-app#overrides[0]': Cannot find module 'typescript' #8936

Open meness opened 4 years ago

meness commented 4 years ago

Describe the bug

When I run eslint: lint whole folder task, it fails because of the error mentioned in the title.

Did you try recovering your dependencies?

Yes, I did.

Which terms did you search for in User Guide?

The issue is not related to any of them, it's ESLint.

Environment

Environment Info:

  current version of create-react-app: 3.4.1
  running from C:\Users\X\AppData\Roaming\npm\node_modules\create-react-app

  System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
  Binaries:
    Node: 12.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Users\X\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.4 - C:\Users\X\AppData\Roaming\npm\npm.CMD
  Browsers:
    Edge: 44.18362.449.0
    Internet Explorer: Not Found
  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

Steps to reproduce

Just run eslint: lint whole folder task.

This is my ESLint config:

{
  "extends": [
    "react-app",
    "airbnb",
    "prettier"
  ],
  "env": {
    "mocha": true,
    "es6": true,
    "commonjs": true,
    "browser": true
  },
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true,
      "modules": true,
      "experimentalObjectRestSpread": true
    }
  },
  "plugins": [
    "prettier"
  ],
  "rules": {
    "no-underscore-dangle": "off",
    "class-methods-use-this": "off",
    "import/no-extraneous-dependencies": [
      "error",
      {
        "devDependencies": true
      }
    ]
  }
}

Expected behavior

It should not throw exceptions.

Actual behavior

It throws the above exception.

Reproducible demo

lancerace commented 2 years ago

make sure your node version is not 12.x . i used a higher version with nvm and it is resolved. (16.14.0)

hmangaiha-dev commented 2 years ago

npm installresolve the issue for me

weeklyTea commented 2 years ago

My problem was solved with next workaround: npm install -D eslint@7.32.0 https://github.com/eslint/eslint/issues/15149#issuecomment-939501275

toddjudd commented 2 years ago

Ran in to this issue with a repo on two different dev machines. Issue was node version. The repo was built for node 16, the machine running node 12 threw this error. Hope this helps someone in the future 👍

skylarmb commented 2 years ago

accidentally using node 12 was also my issue

VishalAkhouri commented 1 year ago

yes, I was getting the issue because I was using node 12.14.x, using v18 resolved it for me.

tonykaram1993 commented 1 year ago

In my case it was an issue with using yarn and npm. No I am not using them together, I always use yarn but this particular project was using npm and by muscle memory I added a package with yarn add <package> but stopped it mid way.

Then I installed it using npm i <package> and issue started happening. Can't guarantee 100% this was the cause, but the timing of stuff made me think that. 🤷‍♂️

My solution was deleting node_modules and install again using npm.

vdavid commented 1 year ago

@tonykaram1993 this was the only solution in the thread that worked for me! Thanks!

AlfieDarko commented 1 year ago

node 12 was also my issue, thanks @tonykaram1993

eXvimmer commented 1 year ago

I'm using eslint_d. In my case, I added node_modules to .eslintignore and then restarted eslint_d (first killed and then ran it again) and it solved the problem.

nicktrandasir commented 1 year ago

I run npm install @typescript-eslint/eslint-plugin@latest --save-dev. Maybe is not the right thing to do but it worked

And need to change path of ESLint package. Settings -> Language & Frameworks -> JavaScript -> Code Quality Tools ->EsLint.
Check field 'Manual ESLint configuration' -> ESLint package. It was ".../current project/node_modules/eslint" and I change path to "C:\Program Files\nodejs\node_modules\eslint" and it's work for me)

p.s. Configuration File -> Automatic search

navinrangar commented 1 year ago

for me upgrading my node version from 12.12.0 to 16.0.0 resolved the issue. Looks like a problem with old node version.

root4554 commented 1 year ago

Changing Node 12 version to the project node version 16 solve the problem for me

talkohavy commented 1 year ago

I figured it out!!

For me it was something else entirely. My project's path contained SPACES!!! Apparently eslint / vscode doesn't know how to deal with spaces in your project's path. That error regarding "Cannot find module 'XXXXX'" is BS, because it doesn't even reach your project's directory, so of course it wouldn't find it! At first I installed and installed over and over again, thinking that it actually isn't installed properly or what not, but this error kept occurring.

The solution:

Move you entire project to a path without spaces, install packages again, and witness the GLORIOUS message of:

1

"Eslint server is running." at last.

Info About My Stuff:

evoytenkoapps commented 1 year ago

i upgraded node.js version to 16 and now it's ok