简体   繁体   English

无法加载在“... » eslint-config-standard”中声明的插件“import”:找不到模块“eslint-plugin-import”

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

I've been trying to use ESLint along with Standard and I haven't been able to get it to work.我一直在尝试将 ESLint 与 Standard 一起使用,但我无法让它工作。 I've tried setting it up through eslint --init, uninstalling eslint globally and having all the packages locally, installing each package manually npm install --save-dev eslint eslint-config-standard eslint-plugin-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-node , reinstalling ESLint extension and nothing so far.我尝试通过 eslint --init 进行设置,全局卸载 eslint 并在本地安装所有软件包,手动安装每个 package npm install --save-dev eslint eslint-config-standard eslint-plugin-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-node ,重新安装 ESLint 扩展,目前还没有。 I'm perfectly able to run ./node_modules/.bin/eslint --fix... in order to fix/check errors but it doesn't work with the VSCode extension by any meanings.我完全能够运行./node_modules/.bin/eslint --fix...来修复/检查错误,但它在任何意义上都不适用于 VSCode 扩展。 I don't have prettier so it isn't related to it either.我没有更漂亮,所以它也与它无关。

Output: Output:

[Info  - 12:33:20 AM] ESLint server is running.
[Info  - 12:33:23 AM] ESLint library loaded from: c:\Users\h08FXplsV8\Documents\dev\node\graphql-bootcamp\graphql-prisma\node_modules\eslint\lib\api.js
[Error - 12:33:25 AM] 
Failed to load plugin 'import' declared in 'graphql-prisma\.eslintrc » eslint-config-standard': Cannot find module 'eslint-plugin-import'
Require stack:
 - C:\Users\h08FXplsV8\Documents\dev\node\graphql-bootcamp\__placeholder__.js
Happened while validating C:\Users\h08FXplsV8\Documents\dev\node\graphql-bootcamp\graphql-prisma\src\resolvers\index.js
This can happen for a couple of reasons:
 - The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
 - If ESLint is installed globally, then make sure 'eslint-plugin-import' is installed globally as well.
 - If ESLint is installed locally, then 'eslint-plugin-import' isn't installed correctly.

.eslintrc: .eslintrc:

{
    "env": {
        "es6": true,
        "node": true
    },
    "extends": [
        "standard"
    ],
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parserOptions": {
        "ecmaVersion": 2018,
        "sourceType": "module"
    },
    "rules": {
    }
}

I've seen other questions in SO related to this issue but none of the solutions worked, unfortunately.我在 SO 中看到了与此问题相关的其他问题,但不幸的是,没有一个解决方案有效。

I had the same issue for many weeks and finally found this thread and comment on Github: https://github.com/microsoft/vscode-eslint/issues/696#issuecomment-542592372我有同样的问题好几个星期了,终于找到了这个帖子并评论了 Github: https://github.com/microsoft/vscode-eslint/issues/696#issuecomment-542592372

My issue turned out to be related to subdirectories.我的问题原来与子目录有关。 As soon as I made the project the only open project with an.eslintrc.js file, all of my linting issues went away.一旦我使该项目成为唯一具有 .eslintrc.js 文件的打开项目,我所有的 linting 问题都消失了。

Hopefully this works for you.希望这对你有用。

To fix the dependency tree, try following these steps in the exact order:要修复依赖关系树,请尝试按确切顺序执行以下步骤

  1. Delete package-lock.json (not package.json.) and/or yarn.lock in your project folder.删除项目文件夹中的 package-lock.json(不是 package.json。)和/或 yarn.lock。
  2. Delete node_modules in your project folder.删除项目文件夹中的 node_modules。
  3. Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.从项目文件夹中 package.json 文件中的依赖项和/或 devDependencies 中删除“babel-eslint”。
  4. Run npm install or yarn, depending on the package manager you use.运行 npm install 或 yarn,具体取决于您使用的 package 管理器。

Also, be sure, that you have latest version of "eslint-plugin-import" plugin, as in my case, for example i had this error with "2.20.1" version, but latest "2.25.3" solved this issue另外,请确保您拥有最新版本的“eslint-plugin-import”插件,例如我的“2.20.1”版本出现此错误,但最新的“2.25.3”解决了这个问题

In my case, i was not using jest at all.就我而言,我根本没有在开玩笑。

So i had to downgrade de eslint dev dependency:所以我不得不降级 de eslint dev 依赖:

"eslint": "^7.32.0",

as it say here: https://github.com/eslint/eslint/issues/15149#issuecomment-939501275正如这里所说: https://github.com/eslint/eslint/issues/15149#issuecomment-939501275

I had the same error caused by the eslint-plugin-import dependency and in my case, I got rid of the error by increasing to the latest version of the package.我遇到了由eslint-plugin-import依赖项引起的相同错误,在我的情况下,我通过升级到最新版本的 package 来消除错误。

For those having the following error with flutter firebase cloud functions after running firebase init functions and trying to run firebase deploy --only functions :对于那些在运行firebase init functions并尝试运行firebase deploy --only functions函数后出现 flutter firebase 云函数错误的用户:

ESLint: 8.9.0
 
Error: Failed to load plugin 'import' declared in '.eslintrc.js': Cannot find module 'es-abstract/2021/RequireObjectCoercible'
Require stack:
- C:\Users\xx\Documents\xx\xx\functions\node_modules\eslint-plugin-import\lib\ExportMap.js
- C:\Users\xx\Documents\xx\xx\functions\node_modules\eslint-plugin-import\lib\rules\named.js
- C:\Users\xx\Documents\xx\xx\functions\node_modules\eslint-plugin-import\lib\index.js
- C:\Users\xx\Documents\xx\xx\functions\node_modules\@eslint\eslintrc\dist\eslintrc.cjs

This was solved by:这是通过以下方式解决的:

  • delete node_modules in functions folder删除函数文件夹中的 node_modules
  • delete package-lock.json in functions folder删除功能文件夹中的 package-lock.json
  • cd.\functions\ in the terminal to get into functions folder, run npm i , cd../ cd.\functions\在终端中进入functions文件夹,运行npm i , cd../
  • firebase deploy --only functions

I am having this issue too which was why I checked this post but did not see any answer that work for me.我也遇到了这个问题,这就是为什么我检查了这篇文章但没有看到任何对我有用的答案。 After searching online, I stumbled into this code which solves my problem.在网上搜索后,我偶然发现了这段代码,它解决了我的问题。

 npm i -D eslint @typescript-eslint/eslint-plugin

I hope this will help you too.我希望这对你也有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载插件导入:'eslint-plugin-import' - Failed to load plugin import: 'eslint-plugin-import' 无法加载在“.eslintrc.json”中声明的插件“react”:找不到模块“eslint-plugin-react” - Failed to load plugin 'react' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-react' 无法加载在“package.json » eslint-config-react-app”中声明的插件“flowtype”:找不到模块“eslint/use-at-your-own-risk” - Failed to load plugin 'flowtype' declared in 'package.json » eslint-config-react-app': Cannot find module 'eslint/use-at-your-own-risk' Heroku 部署失败:无法加载在“package.json”中声明的插件“cypress”:找不到模块“eslint-plugin-cypress” - Heroku deployment failing: Failed to load plugin 'cypress' declared in 'package.json': Cannot find module 'eslint-plugin-cypress' WebStorm eslint-config-standard错误 - WebStorm eslint-config-standard error 如何让 eslint-plugin-import 为我的 npm 项目 (create-react-app) 工作? - How to get eslint-plugin-import working for my npm project (create-react-app)? Npm错误:无法加载插件导入:找不到模块'../docsUrl' - Npm Error: Failed to load plugin import: Cannot find module '../docsUrl' npm init nuxt-app 结果出现问题“无法加载在‘.eslintrc.js » @nuxtjs/eslint-config’中声明的插件‘unicorn’” - npm init nuxt-app results a problem "Failed to load plugin 'unicorn' declared in '.eslintrc.js » @nuxtjs/eslint-config'" 错误:加载 PostCSS 插件失败:找不到模块“postcss-import”(Vue 2) - Error: Loading PostCSS Plugin failed: Cannot find module 'postcss-import' (Vue 2) ESLint eslint-plugin-react箭头功能 - ESLint eslint-plugin-react arrow functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM