Eslint in terminal Can't find module 'eslint-config-react-app'

I am using create-react-app to create react app.

linter works in create-react-app but now I want to make it work in my sublimetext.

  • Installed eslint yarn global add eslint

    (eslint v4.1.1 but also tried v3.19.0 because react app uses that)
  • run eslint --init

    and configure it
  • go to your project directory and make a file named .eslintrc

  • inside the file:
{
"extends": "react-app"
}

      

  1. run in project directory eslint src/App.js

  2. get error in terminal:

    Ref: /mnt/storage/Dev/newapp/.eslintrc Error: Cannot find module "eslint-config-react-app"

    Ref: /mnt/storage/Dev/newapp/.eslintrc on ModuleResolver.resolve (/home/user/.config/yarn/global/ node_modules / eslint / lib / util / module-resolver.js: 74: 19) in solution (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:515:25) at boot (/home/user/.config/yarn/global/node_modules/eslint/ lib / config / config-file.js: 584: 26) at configExtends.reduceRight (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:421:36) at Array.reduceRight (native) on applyExtends (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:405:28) on loadFromDisk (/home/user/.config/ yarn / global / node_modules / eslint / lib / config / config-file.js: 556: 22) in Object.load (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file .js: 592: 20) in Config.getLocalConfigHierarchy (/home/user/.config/yarn/global/node_modules/eslint/lib/config.js:228:44) in Config.getConfigHierarchy (/home/user/.config/yarn/global/node_modules/eslint/lib /config.js:182:43)

I added yarn global add babel-eslint eslint-plugin-react eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-flowtype

. but I think it is no longer needed!

+9


source to share


4 answers


I think if you add the module mentioned in the error message ( eslint-config-react-app

) it should work? eg.yarn add --dev eslint-config-react-app



+3


source


So, I found out that you need to install "all" packages eslint global. because it won't let you deal with eslint global and local packages



so what i did yarn global add eslint@^3.19.0 eslint-plugin-jsx-a11y@^5.0.

and now it works: |

+2


source


Probably a misconfiguration in your file package-lock.json

where ESLint was removed. I faced exactly the same problem and solved it with:

  1. cd <your-project-directory>

  2. rm package-lock.json

  3. rm -rf node_modules

  4. npm install

You can run npm ls eslint --depth=99

to make sure the package is eslint

installed. I came across this via a comment from feross on GitHub.

0


source


First install this package, ESLint and required plugins.

npm install --save-dev eslint-config-react-app babel-eslint@9.x eslint@5.x eslint-plugin-flowtype@2.x eslint-plugin-import@2.x eslint-plugin-jsx-a11y@6.x eslint-plugin-react@7.x

      

Then create a file named .eslintrc.json with the following content in your project root folder:

 {
  "root": true,
  "ecmaFeatures": {
    "jsx": true
  },
  "env": {
    "browser": true,
    "node": true,
    "jquery": true
  },
  "rules": {
    "quotes": 0,
    "no-trailing-spaces": 0,
    "eol-last": 0,
    "no-unused-vars": 0,
    "no-underscore-dangle": 0,
    "no-alert": 0,
    "no-lone-blocks": 0
  },
  "globals": {
    "jQuery": true,
    "$": true
  }
}

      

See link

0


source







All Articles