btholt / complete-intro-to-react

A Complete Intro to React, as Given for Frontend Masters
https://frontendmasters.com/learn/react/
MIT License
1.06k stars 929 forks source link

Cannot find module 'eslint-config-prettier/react' #66

Closed f00z closed 7 years ago

f00z commented 7 years ago

When using $ eslint **/*.{js,jsx} --quiet I get the following error:

image

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?

f00z commented 7 years ago

I 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} --quiet similar issue: https://github.com/eslint/eslint/issues/1238

Ciwan1859 commented 7 years ago

@f00z shouldn't yarn automatically be checking the local node_modules folder? I'm having the same issue.

f00z commented 7 years ago

@Ciwan1859 As you have pointed our in your stackoverflow post, globally installed yarn cannot see locally installed eslint unless local path is specified. I haven't tried out the devDependencies route

antonyadhiban commented 7 years ago

yarn install prettier (or) nom install prettier instead of doing global install. make sure eslint and prettier are present in local node_modules folder

Ciwan1859 commented 7 years ago

@antonyadhiban I tried that too, and still get the same error.

beauhaus commented 7 years ago

@Ciwan1859 Wonder if you've found a better solution to this yet, by chance.

@f00z 's line./node_modules/.bin/eslint **/*.{js,jsx} --quiet is the only line that works for me.

Ciwan1859 commented 7 years ago

Sadly not @Beauvelop I'm still stuck with this :( nothing seems to work for me.

beauhaus commented 7 years ago

Ugh... ok. I'll look around for a solution to this, if it exists... Good Luck.

tlrjs commented 7 years ago

@Ciwan1859 @Beauvelop Have you tried adding in "eslint-loader": "1.7.1" Brian mentions in the videos that adding this solves the problem

Ciwan1859 commented 7 years ago

@tjshipe I just did a yarn add eslint-loader --dev to install the package, then tried yarn lint again, but it failed again. I still get the same error.

image

MirayaReie commented 7 years ago

@Ciwan1859 as a windows user i actually solved the problem. I uninstalled yarn completely. Then I installed it via .msi installer from official site. Added yarn bin from installation folder to path manually (it wasn't there after installation). And after all these steps I installed esling via yarn global install eslint. I guess, problem was from istallation of yarn as npm dependancy (like in video lecture), though, I don't know how it works internally.

Steveiscreative commented 7 years ago

Running it locally seemed to work for me. Adding "lint": eslint **/*.{js,jsx} to my packages.json, then running yarn link worked 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.

vic6 commented 7 years ago

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 } }

Tom2277 commented 7 years ago

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.js

and (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-prettier

Still scratching my head about why it won't work from a script but onto other things

aprylisnow commented 6 years ago

I'm having the same issues. None of the above recommendations have worked for me. Not sure what to try next.

dilantha111 commented 6 years ago

For me yarn eslint **/*.{js,jsx} --quiet worked

prakash-ism commented 6 years ago

For me it worked but I have to perform some additional steps. I also have to install all the dependencies that were coming in the error screen of command "eslint */.{js,jsx} --quiet". Finally I came to error "Cannot find module 'eslint-config-prettier/react'". After this, include the link to package.json.After this I think the issue is with local and global installs of npm and the calls being made probably.

m-ret commented 6 years ago

First run $ sudo yarn global add eslint-config-with-prettier I had to use sudo and then I tried with double quotes and it worked for me. I did: eslint "**/*.{js,jsx}" --quiet instead of eslint **/*.{js,jsx} --quiet

robert-paul commented 6 years ago

The solution mentioned by @f00z is the only thing that worked for me.

In package.json, made a script called "lint" and pointed it directly to the node module "./node_modules/.bin/eslint */.{js,jsx} --quiet"

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "format": " prettier --write --single-quote --print-width=120 --parser=flow --tab-width=2 \"src/**/*.{js,jsx}\" ",
    "lint": "./node_modules/.bin/eslint **/*.{js,jsx} --quiet"
  }
mdmaroof commented 6 years ago

screen shot 2018-06-27 at 10 46 20 am

can someone help me with this error

joshuabahr commented 6 years ago

I'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.

pom421 commented 6 years ago

For 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

marcelmokos commented 6 years ago

This can happen when you are missing peer dependency.

yarn add --dev eslint-config-prettier

code4cake commented 6 years ago

What actually end up solving the problem for me.

  1. Installed all eslint and prettier files as local dependencies yarn add -D eslint eslint-plugin-prettier prettier eslint-config-prettier
  2. Create a script inside my package.json for eslint :
...omitted_code

    "format": "prettier --write --single-quote --print-width=120 --parser=flow --tab-width=2 \"js/**/*.{js,jsx}\"",
    "lint": "eslint \"**/*.{js,jsx}\" --quiet"

...omitted_code
  1. yarn run lint should give you the desire output : ✖ 2 problems (2 errors, 0 warnings) if you are watching the Eslint Lecture