Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load plugin 'import' declared in '--config » eslint-config-standard': Cannot find module 'eslint' #1439

Closed
marcospgp opened this issue Oct 14, 2019 · 20 comments

Comments

@marcospgp
Copy link

Failed to load plugin 'import' declared in '--config » eslint-config-standard': Cannot find module 'eslint'

Should I install eslint? Couldn't find this information in the readme.

Thanks!

@mightyiam
Copy link
Member

Hi, @marcospgp. Thank you for using Standard. To begin helping you, I'd like more information. Could you please submit a new issue with all of the issue template filled in? For our convenience, I'll close this one.

@marcospgp
Copy link
Author

@mightyiam I'm sorry, I don't have the time right now. I just installed standard so it's the latest version. Ran on VSCode on Windows. Standard is the only project dependency.

@mightyiam
Copy link
Member

Could you please run npm --version and node --version and paste the results here?

@marcospgp
Copy link
Author

For sure!

$ npm --version
6.11.3

$ node --version
v10.16.0

@mightyiam
Copy link
Member

How are you running standard, please? Is it via the command line in VSCode or via some extension?

@marcospgp
Copy link
Author

marcospgp commented Oct 14, 2019

I tried both with the integrated command line in VSCode (bash) and through the VSCode extension, both show the same error.

@mightyiam
Copy link
Member

Could you please paste the result of the npm ls eslint command?

@LinusU
Copy link
Member

LinusU commented Oct 15, 2019

I have this consistently failing on Travis CI! 😄

https://travis-ci.org/LinusU/node-albatross/jobs/597540373

$ node --version
v12.12.0
$ npm --version
6.11.3
standard: Unexpected linter output:

Error: Failed to load plugin 'import' declared in '--config » eslint-config-standard': Cannot find module 'eslint'
Require stack:
- /home/travis/build/LinusU/node-albatross/node_modules/eslint-plugin-import/lib/ExportMap.js
- /home/travis/build/LinusU/node-albatross/node_modules/eslint-plugin-import/lib/rules/named.js
- /home/travis/build/LinusU/node-albatross/node_modules/eslint-plugin-import/lib/index.js
- /home/travis/build/LinusU/node-albatross/node_modules/standard/node_modules/eslint/lib/cli-engine/config-array-factory.js
- /home/travis/build/LinusU/node-albatross/node_modules/standard/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js
- /home/travis/build/LinusU/node-albatross/node_modules/standard/node_modules/eslint/lib/cli-engine/cli-engine.js
- /home/travis/build/LinusU/node-albatross/node_modules/standard/node_modules/eslint/lib/cli-engine/index.js
- /home/travis/build/LinusU/node-albatross/node_modules/standard/node_modules/eslint/lib/api.js
- /home/travis/build/LinusU/node-albatross/node_modules/standard/options.js
- /home/travis/build/LinusU/node-albatross/node_modules/standard/bin/cmd.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/travis/build/LinusU/node-albatross/node_modules/eslint-plugin-import/lib/ExportMap.js:20:15)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)

I wonder if the problem is that eslint isn't getting hoisted up, and thus the other modules can't find it? Since it's only required by standard:

$ npm ls eslint          
albatross@1.1.0 /Users/linus/coding/node-albatross
└─┬ standard@14.3.1
  └── eslint@6.4.0 

@LinusU LinusU reopened this Oct 15, 2019
@LinusU
Copy link
Member

LinusU commented Oct 15, 2019

Hmm, maybe this is related?

This @npmjs bug randomly makes ESLint installation fail when a package which has a name alphabetically before 'eslint' depends on an older version of 'acorn' eslint/espree#393

https://twitter.com/feross/status/1161900081492234240

Not exactly the same though? 🤔

@LinusU
Copy link
Member

LinusU commented Oct 15, 2019

This makes it seem like npm is simply not installing eslint package though 🤔

npm WARN eslint-config-standard@14.1.0 requires a peer of eslint@>=6.2.2 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-standard-jsx@8.1.0 requires a peer of eslint@>=6.2.2 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-es@2.0.0 requires a peer of eslint@>=4.19.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-import@2.18.2 requires a peer of eslint@2.x - 6.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-node@10.0.0 requires a peer of eslint@>=5.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react@7.14.3 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-standard@4.0.1 requires a peer of eslint@>=5.0.0 but none is installed. You must install peer dependencies yourself.

@mightyiam
Copy link
Member

@LinusU, if you have a local installation where this is occurring, could you please type in npm ls eslint to see if and where it is I stalled?

@LinusU
Copy link
Member

LinusU commented Oct 26, 2019

Unfortunately, I haven't been able to reproduce this locally yet. Hopefully I can take some time soon to reproduce this inside an Ubuntu Docker container ☺️

@LinusU
Copy link
Member

LinusU commented Nov 13, 2019

This seems to be fixed with all the latest versions now.

@marcospgp can you try and trash your node_modules/ and package-lock.json, then install again and see if it works? Happy to re-open if you are still having problems!

@LinusU LinusU closed this as completed Nov 13, 2019
@AndyOGo
Copy link

AndyOGo commented Dec 8, 2019

I just got the same error, turns out standard was upgraded in package.json, but a local package-lock.json (but wasn't commited and in gitignore file), caused it that another version was used...

So I deleted the package-lock file and reinstalled everything. Hope it helps someone.

@mightyiam
Copy link
Member

Thank you for the tip, @AndyOGo .

@prateekrastogi
Copy link

@AndyOGo Worked pretty well for me too

@Fuzzyma
Copy link

Fuzzyma commented Jun 19, 2020

I have the same error but only when I want to use it with VSCode. The ESLint tab shows this:

[Info  - 10:30:15] ESLint server stopped.
[Info  - 10:30:15] ESLint server running in node v12.8.1
[Info  - 10:30:15] ESLint server is running.
[Info  - 10:30:18] ESLint library loaded from: <path>\root\node_modules\eslint\lib\api.js
[Error - 10:30:19] 
Failed to load plugin 'import' declared in '<path>\root\.eslintrc.js » eslint-config-standard': Cannot find module 'eslint-plugin-import'
Require stack:
- <path>\__placeholder__.js
Happened while validating <path>\root\.eslintrc.js
This can happen for a couple of reasons:
1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
2. If ESLint is installed globally, then make sure 'eslint-plugin-import' is installed globally as well.
3. If ESLint is installed locally, then 'eslint-plugin-import' isn't installed correctly.

Consider running eslint --debug <path>\root\.eslintrc.js from a terminal to obtain a trace about the configuration files used.

The require stack is a bit strange because it starts from the project root and not from the eslint root.

@Fuzzyma
Copy link

Fuzzyma commented Jun 19, 2020

Ok for VSCode try this solution in case your eslint root is not your project root: microsoft/vscode-eslint#196

@charleycodes
Copy link

@AndyOGo I was having a similar problem - deleted the yarn.lock file and re-ran yarn - the error is gone!

@Gris229
Copy link

Gris229 commented Feb 23, 2022

@charleycodes you mean re-ran yarn install ?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

8 participants