complete-intro-to-react: Cannot find module 'eslint-config-prettier/react'
When using $ eslint **/*.{js,jsx} --quiet I get the following error:

and here is my .eslintrc.json `{ “extends”:[ “airbnb”, “prettier”, “prettier/react” ], “plugins”:[ “prettier” ], “parserOptions”:{ “ecmaVersion”:2016, “sourceType”:“module”, “ecmaFeatures”: { “jsx”:true } }, “env”:{ “es6”:true, “browser”:true, “node”:true } }
Any ideas what I am doing wrong?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24
This can happen when you are missing peer dependency.
yarn add --dev eslint-config-prettierI had to use locally installed eslint to fix this error so when I reference local copy of eslint it works fine:
./node_modules/.bin/eslint **/*.{js,jsx} --quietsimilar issue: https://github.com/eslint/eslint/issues/1238Running it locally seemed to work for me. Adding
"lint": eslint **/*.{js,jsx}to my packages.json, then runningyarn linkworked for me. My guess is when you use eslint in the command line, it’s looking at your global packages and not your local. When running yarn lint, it’s looking at your local packages.For me
yarn eslint **/*.{js,jsx} --quietworked@Ciwan1859 Wonder if you’ve found a better solution to this yet, by chance.
@f00z 's line
./node_modules/.bin/eslint **/*.{js,jsx} --quietis the only line that works for me.I could not get the script command working for the life of me, but I WAS able to get the command line call of
>eslint js/ClientApp.jsand (testing with only one other fake file at this time)
>eslint */*.{js, jsx}too (which gave me results without err for both files)
AFTER I globally installed
yarn global add eslint-config-with-prettierStill scratching my head about why it won’t work from a script but onto other things
What actually end up solving the problem for me.
eslintandprettierfiles as local dependenciesyarn add -D eslint eslint-plugin-prettier prettier eslint-config-prettierpackage.jsonforeslint:yarn run lintshould give you the desire output :✖ 2 problems (2 errors, 0 warnings)if you are watching the Eslint LectureFor future readers, I had the same problem and @joshuabahr puts me in track.
The eslint-plugin-react must be installed globally if the eslint is already installed globally, as documented here : https://github.com/yannickcr/eslint-plugin-react#installation
So i suggest to install the 2 npm locally, that seems a more clean approach.
npm install --save-dev eslint npm install --save-dev eslint-plugin-react
First run
$ sudo yarn global add eslint-config-with-prettierI had to usesudoand then I tried with double quotes and it worked for me. I did:eslint "**/*.{js,jsx}" --quietinstead ofeslint **/*.{js,jsx} --quietI’ve gotten the exact same error as mdmaroof, can’t find “node_modules/asn1.js”
Actually just found a solution, I believe. I had installed locally a more current version of ESlint. Run
yarn add --dev eslint@3.19.0, it is the version being used in the course.However, like others, I have to point to the local version of eslint (./node_modules/.bin/eslint) or else it will not run. If I try to run using globally installed eslint, it continues to say cannot find module eslint-config-prettier/react. Trying to perform a global install of the module gives me an error.
It looks like his completed branch is different than if you are following along, changing .eslintrc.json to this fixed it for me.
{ "extends": [ "plugin:flowtype/recommended", "airbnb", "prettier", "prettier/react" ], "plugins": ["flowtype", "prettier"], "parser": "babel-eslint", "parserOptions": { "ecmaVersion": 2016, "sourceType": "module", "ecmaFeatures": { "jsx": true } }, "env": { "es6": true, "jest": true, "browser": true, "node": true }, "globals": { "DEBUG": false } }@Ciwan1859 @Beauvelop Have you tried adding in
"eslint-loader": "1.7.1"Brian mentions in the videos that adding this solves the problemyarn install prettier (or) nom install prettier instead of doing global install. make sure eslint and prettier are present in local node_modules folder