【问题标题】:ESLint couldn't find the plugin "eslint-plugin-react"ESLint 找不到插件“eslint-plugin-react”
【发布时间】:2021-02-13 07:19:28
【问题描述】:

我在 sublime-text 3 中工作,项目结构如下:

workdir

--root-project-dirictory

---- src

---- eslint.yml

--project.sublime-project

问题是这样的:ESLintworkdir 中而不是在 root-project-dirictory 中寻找 eslint-plugin-react 插件。

结果我得到一个错误:

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "/.../workdir".)

...

The plugin "eslint-plugin-react" was referenced from the config file in "root-project-dirictory / .eslintrc.yml".

【问题讨论】:

标签: sublimetext eslint


【解决方案1】:

问题是这样的:ESLint 在 workdir 中而不是在根项目目录中寻找 eslint-plugin-react 插件。

如果eslint-plugin-react 包含在根工作目录中,那么它应该安装在根目录中,然后您可以从根目录扩展子配置。

【讨论】:

  • 当你的父目录有 .eslintrc 或 .eslintrc.yml 时发生
【解决方案2】:

直到现在,在不改变工作目录结构的情况下,我还没有找到解决这个问题的方法。

作为解决方案,我使用以下方法:

  • 创建一个空的 sublime-text 项目

  • 在项目中一一添加文件夹,如“src”、“app”...

  • 如果 --root-project-dirictory 中需要文件,则添加它,但我正在项目的单独 sublime-text 文件夹中处理应用程序

【讨论】:

  • 请看一下几乎与此重复的问题。这很可能是 ESLint v6 问题
【解决方案3】:

我遇到了同样的问题,并找到了主要原因以及如何解决:

npx eslint . --fix
Oops! Something went wrong! :(
ESLint: 6.1.0.
ESLint couldn't find the plugin "eslint-plugin-import".

还是这个错误

Error: Cannot find module 'eslint-config-airbnb'

要修复它运行这个:

$ rm -rf node_modules

$ npm install eslint --save
$ npm install eslint-config-airbnb-base --save
$ npm install eslint-plugin-markdown --save
$ npm install eslint-plugin-import --save

(install all other plugins)

$ npm i
$ npx eslint --version

(should be less than 7)

现在,它可以工作了:

npx eslint . --fix

原因: 似乎如果在 dev reps 下列出的库,ESLint 会自动更新到尚未准备好的 7.0。如您所见,我们有the same error before on version 6.

【讨论】:

    【解决方案4】:

    对我来说,问题是我在全球范围内使用没有那个插件的 eslint。我用了npx eslint ...这个命令就正常了。

    【讨论】:

      猜你喜欢
      • 2019-07-30
      • 2018-07-04
      • 2021-04-08
      • 2019-06-28
      • 2016-05-27
      • 1970-01-01
      • 2023-03-27
      • 2018-04-21
      • 2017-09-13
      相关资源
      最近更新 更多