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"
}
- run in project directory
eslint src/App.js
-
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!
source to share
Probably a misconfiguration in your file package-lock.json
where ESLint was removed. I faced exactly the same problem and solved it with:
-
cd <your-project-directory>
-
rm package-lock.json
-
rm -rf node_modules
-
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.
source to share
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
}
}
source to share