Create-react-app: Cannot find module 'eslint-config-react-app'

Created on 21 Dec 2017  Â·  10Comments  Â·  Source: facebook/create-react-app

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Didn't try 4. I'm using lts/carbon with yarn.

Which terms did you search for in User Guide?

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.

Environment

  1. node -v: 8.9.3
  2. npm -v: 5.5.1
  3. yarn --version (if you use Yarn): 1.3.2
  4. npm ls react-scripts (if you haven’t ejected): 1.0.17

Then, specify:

  1. Operating system: macOS 10.12.6
  2. Browser and version (if relevant): Chrome/N/A

Steps to Reproduce

(Write your steps here:)

  1. create-react-app eslint-dep
  2. cd eslint-dep
  3. yarn global add eslint
  4. echo '{"extends": "react-app"}' > .eslintrc
  5. eslint src

Expected Behavior

I thought I'd have all the necessary eslint plugins to run eslint src with the react-app plugin.

Actual Behavior

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.

question

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:

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

All 10 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fson picture fson  Â·  3Comments

JimmyLv picture JimmyLv  Â·  3Comments

jnachtigall picture jnachtigall  Â·  3Comments

alleroux picture alleroux  Â·  3Comments

alleroux picture alleroux  Â·  3Comments