Skip to content

ESLint is not running, error: "Cannot find module" #3998

Closed

Description

@jpaulomotta

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes.

yarn --version 1.3.2

Which terms did you search for in User Guide?

Displaying Lint Output in the Editor

Environment

  1. node -v: v8.9.4
  2. npm -v: 5.6.0
  3. yarn --version :1.32
  4. npm ls react-scripts (if you haven’t ejected):
    eslint-test@0.1.0 /Users/Joao/code/node/eslint-test
    └── react-scripts@1.1.0
  5. yarn eslint --version: v4.17.0

Node LTS, latest version of yarn

Then, specify:

  1. Operating system: MacOS High Sierra 10.13.2
  2. Browser and version (if relevant):

Steps to Reproduce

  1. Run in terminal
create-react-app eslint-test
cd eslint-test/
yarn add eslint -D
  1. Create file .eslintrc in project root
  2. Add this content to the .eslintrc file:
{
  "extends": "react-app"
}
  1. Run yarn
  2. Run yarn eslint src/App.js --debug

Expected Behavior

I though ESLINT would parse the file App.js
ESLint was supposed to work because I have followed the instructions on the documentation at "Displaying Lint Output in the Editor"

Actual Behavior

I'm getting the error Cannot find module 'eslint-config-react-app'

The output of yarn eslint src/App.js --debug:

screen shot 2018-02-08 at 4 41 53 pm

The command npm ls eslint-config-react-app prints:

eslint-test@0.1.0 /Users/Joao/code/node/eslint-test
└─┬ react-scripts@1.1.0
  └── eslint-config-react-app@2.1.0 

This issue was fixed running the command: yarn add -D eslint-config-react-app 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

This issue took quite a while to be resolved.
Should this command be documented at "Displaying Lint Output in the Editor" or "Troubeshoot"? Others could be facing the same problem.

Reproducible Demo

Run the commands on Steps to reproduce.

Activity

  1. gaearon commented on Feb 9, 2018

    @gaearon
    Contributor

    Yeah I think our docs currently assume the dependency is being hoisted but Yarn probably doesn’t do this.

  2. gaearon commented on Feb 9, 2018

    @gaearon
    Contributor

    Maybe we could re-export the config as react-scripts/eslint so we don’t need to rely on hoisting.

  3. jpaulomotta commented on Feb 9, 2018

    @jpaulomotta
    Author

    How could I help with this?

    I read the source code of eslint-config-react-app but I don't know how this re-export could be made.

  4. stale commented on Nov 2, 2018

    @stale

    This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

  5. locked and limited conversation to collaborators on Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions