Yes
Didn't try 4. I'm using lts/carbon with yarn.
I looked through the user guide and found Usage in Create React App Projects which indicates that it should be available as part of Create React App.
node -v
: 8.9.3npm -v
: 5.5.1yarn --version
(if you use Yarn): 1.3.2npm ls react-scripts
(if you haven’t ejected): 1.0.17Then, specify:
(Write your steps here:)
create-react-app eslint-dep
cd eslint-dep
yarn global add eslint
echo '{"extends": "react-app"}' > .eslintrc
eslint src
I thought I'd have all the necessary eslint plugins to run eslint src with the react-app plugin.
Cannot find module 'eslint-config-react-app'
Referenced from: /Users/typeoneerror/Dev/eslint-bug/.eslintrc.json
Error: Cannot find module 'eslint-config-react-app'
This may be simply a dependency issue, but it may be a documentation issue as the eslint-config-react-app
package says I should have this already as part of CRA.
Could you please show output of npm ls eslint-config-react-app
? E.g. mine.
➜ test: npm ls eslint-config-react-app
[email protected] /private/tmp/test
└─┬ [email protected]
└── [email protected]
I don't think we support running something like eslint src
globally.
Why do you need this?
Lint already runs as part of yarn start
or yarn build
. You don't need to do anything extra to run it.
@gaearon Yes, I realized that once I started working seriously with VS Code. I thought maybe it would run on its own as part or a built step or something. My apologies, this is my first React project!
No problem :-)
For anyone else trying this, one solution is installing eslint-config-react-app
globally, along with all of its peer deps. At the moment, that's:
npm i -g babel-eslint@^7.2.3 eslint@^4.1.1 eslint-plugin-flowtype@^2.34.1 eslint-plugin-import@^2.6.0 eslint-plugin-jsx-a11y@^5.1.1 eslint-plugin-react@^7.1.0
@lorensr It didn't work for me..
I tried installing it globally using your command, which resulted in: (seems correct)
$ npm i -g babel-eslint@^7.2.3 eslint@^4.1.1 eslint-plugin-flowtype@^2.34.1 eslint-plugin-import@^2.6.0 eslint-plugin-jsx-a11y@^5.1.1 esl
int-plugin-react@^7.1.0
C:\Program Files\nodejs\eslint -> C:\Program Files\nodejs\node_modules\eslint\bin\eslint.js
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
added 116 packages and updated 3 packages in 74.992s
But then doing npm ls eslint-config-react-app
as @miraage said returns:
$ npm ls eslint-config-react-app
[email protected] \private\path\test-app
-- (empty)
So I'm a bit confused by this now.
npm ls only lists packages installed in the local app I believe.
Cannot find module 'eslint-config-react-app' Referenced from
*[Info - 2:16:23 PM] ESLint server is running.
[Info - 2:16:31 PM] ESLint library loaded from: C:\Usersxyz\AppData\Roamingnpm\node_modules\eslint\lib\api.js
[Error - 2:17:00 PM] Cannot find module 'eslint-config-react-app' Referenced from: C:\Usersxyz\
project exquizme\ExQuizMe-master\client.eslintrc *
anyone say something about this error plz, to be honest, I am really new in React js.
You have to have the 'eslint-config-react-app' package in the same "scope" of your eslint installation. If you installed eslint globally (by using 'npm install -g eslint' or 'yarn global add eslint') you should do the same for "eslint-config-react-app"... if you installed locally (npm without -g or yarn without global), you should install the config package in the same way.
I can't see your package.json file so I will just write what was my problem and how I solved it.
I was using eslintrc file and eslint obviously but i used extended libraries from tslint such as _tslint-react_
notice the difference TSlint and ESlint..
Most helpful comment
For anyone else trying this, one solution is installing
eslint-config-react-app
globally, along with all of its peer deps. At the moment, that's: