Closed f00z closed 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
@f00z shouldn't yarn
automatically be checking the local node_modules
folder? I'm having the same issue.
@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
yarn install prettier (or) nom install prettier instead of doing global install. make sure eslint and prettier are present in local node_modules folder
@antonyadhiban I tried that too, and still get the same error.
@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.
Sadly not @Beauvelop I'm still stuck with this :( nothing seems to work for me.
Ugh... ok. I'll look around for a solution to this, if it exists... Good Luck.
@Ciwan1859 @Beauvelop Have you tried adding in "eslint-loader": "1.7.1"
Brian mentions in the videos that adding this solves the problem
@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.
@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.
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.
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 } }
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
I'm having the same issues. None of the above recommendations have worked for me. Not sure what to try next.
For me
yarn eslint **/*.{js,jsx} --quiet
worked
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.
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
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"
}
can someone help me with this error
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.
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
This can happen when you are missing peer dependency.
yarn add --dev eslint-config-prettier
What actually end up solving the problem for me.
eslint
and prettier
files as local dependencies yarn add -D eslint eslint-plugin-prettier prettier eslint-config-prettier
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
yarn run lint
should give you the desire output : ✖ 2 problems (2 errors, 0 warnings)
if you are watching the Eslint Lecture
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?