Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Error: Cannot find module 'eslint-plugin-react' #270

Closed
aravindet opened this issue Nov 15, 2015 · 28 comments
Closed

Error: Cannot find module 'eslint-plugin-react' #270

aravindet opened this issue Nov 15, 2015 · 28 comments

Comments

@aravindet
Copy link

After upgrading to Atom 1.2.1, and linter-eslint 5.0.1, I see:

Error: Cannot find module 'eslint-plugin-react'
    ... (module.js lines omitted)
    at /home/<username>/.atom/packages/linter-eslint/node_modules/eslint/lib/cli-engine.js:124:26

It is not detecting the project-local eslint and eslint-plugin-react. It was working correctly, in the same project, with 1.1.0 and the previous version of linter-eslint.

@steelbrain
Copy link
Contributor

I think this has already been fixed in master. I'll tag a release when I am done with the windows support in a few hours

@steelbrain
Copy link
Contributor

v5.0.2 is out that fixes this

@longseespace
Copy link

@steelbrain I got the same issue with Atom 1.3.1, linter-eslint 5.2.6. Can you give a check?

Error: Cannot find module 'eslint-plugin-react'
    ... (module.js lines omitted)
    at /home/<username>/.atom/packages/linter-eslint/node_modules/eslint/lib/cli-engine.js:125:26

@Arcanemagus
Copy link
Member

@longseespace you are loading the eslint bundled with this package, is it not detecting the one installed to your project?

@danielbuechele
Copy link

I am having the same issue on Atom 1.3.1 and linter-eslint 5.2.6. This is from my package.json:

"devDependencies": {
    "babel-eslint": "^5.0.0-beta6",
    "eslint": "^1.10.3",
    "eslint-plugin-babel": "^3.0.0",
    "eslint-plugin-react": "^3.11.3"
  }

none of these is installed globally. I want Atom to use the local ones.

@brandonaaskov
Copy link

For future travelers coming across this like I did, my issue was that I was missing this all-important line in my .eslintrc file:

"parser": "babel-eslint"

There are a handful of reasons this could in Atom, but for me, this was the culprit.

@danielbuechele
Copy link

Good point! But in my case this doesn't fix the problem.

@Arcanemagus
Copy link
Member

@danielbuechele can you post your eslint configuration as well?

@danielbuechele
Copy link

danielbuechele commented Dec 14, 2015

{
    "rules": {
        "quotes": [1,"single"],
        "linebreak-style": [2,"unix"],
        "semi": [2,"always"],
        "comma-dangle": [1, "never"],
        "react/no-direct-mutation-state": 2,
        "react/prop-types": [2, {"ignore": "store"}],
        "react/sort-comp": [2, {
            "order": [
                "lifecycle",
                "everything-else",
                "rendering"
            ],
            "groups": {
                "rendering": ["/^render. + $ / ", "render"]
            }
        }],
        "react/jsx-max-props-per-line": [1, { "maximum": 3 }],
        "react/jsx-no-duplicate-props": [2, { "ignoreCase": true }],
        "react/jsx-quotes": 0,
        "jsx-quotes": [2, "prefer-double"]
    },
    "env": {
        "es6": true,
        "node": true,
        "browser": true
    },
    "extends": "eslint:recommended",
    "ecmaFeatures": {
        "jsx": true,
        "modules": true,
        "experimentalObjectRestSpread": true
    },
    "plugins": [
      "react",
      "babel"
    ]
}

@IanVS
Copy link
Member

IanVS commented Dec 16, 2015

@danielbuechele, where do you have ESLint installed, and where do you have the plugins installed? They need to be in the same place.

@danielbuechele
Copy link

eslint and plugins are both installed as local dev-dependencies.

@IanVS
Copy link
Member

IanVS commented Dec 16, 2015

Can you post the error message you are getting?

@danielbuechele
Copy link

Error: Cannot find module 'eslint-plugin-react'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at /Users/dani/Dropbox/Apps/Atom/packages/linter-eslint/node_modules/eslint/lib/cli-engine.js:125:26
    at Array.forEach (native)
    at loadPlugins (/Users/dani/Dropbox/Apps/Atom/packages/linter-eslint/node_modules/eslint/lib/cli-engine.js:116:21)
    at processText (/Users/dani/Dropbox/Apps/Atom/packages/linter-eslint/node_modules/eslint/lib/cli-engine.js:204:5)
    at CLIEngine.executeOnText (/Users/dani/Dropbox/Apps/Atom/packages/linter-eslint/node_modules/eslint/lib/cli-engine.js:686:26)
    at Object.cli.execute (/Users/dani/Dropbox/Apps/Atom/packages/linter-eslint/node_modules/eslint/lib/cli.js:162:36)

@IanVS
Copy link
Member

IanVS commented Dec 16, 2015

It looks like linter-eslint is using the version of ESLint that comes bundled with itself, and is not picking up your local version. What versions are you on (linter-eslint, eslint, etc.)? Do you have a non-standard directory structure? From your project directory, what do you get from node_modules/.bin/eslint -v?

@danielbuechele
Copy link

node_modules/.bin/eslint -v returns v1.10.3.

Atom:

  • linter: 1.11.3
  • linter-eslint: 5.2.6

package.json (as devDependencies):

  • babel-eslint: ^5.0.0-beta6
  • eslint: ^1.10.3
  • eslint-plugin-babel: ^3.0.0
  • eslint-plugin-react: ^3.11.3

@IanVS
Copy link
Member

IanVS commented Dec 16, 2015

What settings do you have enabled for linter-eslint? Any other clues you can give about your project structure?

@brandonaaskov
Copy link

Yeah, @danielbuechele if you can simplify your project/repo to make it shareable (the actual code isn't even needed here aside from a single file to test linting on), it'll help speed up troubleshooting.

@danielbuechele
Copy link

Okay, I just created a copy of my project and removed some dependencies and stuff and now it works. I try to figure out what causes the issue.

@lmuntaner
Copy link

Hello! I have the same problem. Which dependencies did you remove to have it working?
Thanks!

@danielbuechele
Copy link

I still couldn't figure out what the problem is. I removed and readded some dependencies, then it was working. Can't say what caused the problem.

@lmuntaner
Copy link

Thanks for the response! I also got it working without identifying the problem...

@evaristoc
Copy link

I had the same problem with Atom. I have a Windows10 computer without node/npm installed in it. However I installed last version of Atom two days ago.

Few hours ago from the time of this message I try to install linter and then linter-eslint using apm (atom package manager). After installation with apm it appeared a simple message for each: "installation done". However when checking for dependencies, those were not found anywhere in the computer, especifically eslint-plugin-react.

Error as in this thread.

Is Atom still requiring to have npm globally available to complete the installation of linter-eslint?

@Arcanemagus
Copy link
Member

@evaristoc eslint-plugin-react is not a dependency of linter-eslint. If you need that plugin in your project you should install a local version of eslint with that plugin in your project. If for some reason this is not possible you would need to install eslint globally along with that plugin.

linter-eslint only bundles plain eslint to provide basic linting, anything more advanced (including plugins) should be done at the project level, which would mean needing node installed on your machine.

@evaristoc
Copy link

Thanks, Arcanemagus. Thought they were shipped together.

@stiofand
Copy link

Still no fix, then, this is pretty annoying and is stopping any work I can do in Atom

@IanVS
Copy link
Member

IanVS commented Jan 18, 2017

The "fix" is to install eslint-plugin-react if you are choosing to use that plugin.

This is not a bug in linter-eslint, @stevematdavies.

@stiofand
Copy link

@IanVS I have all that installed locally and in my project

@IanVS
Copy link
Member

IanVS commented Jan 18, 2017

Can you please open a new issue and fill out the issue template completely, if you believe this to be a bug?

@AtomLinter AtomLinter locked and limited conversation to collaborators Jan 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants