node.js 无法加载插件导入:'eslint-plugin-import'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45073612/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:21:47  来源:igfitidea点击:

Failed to load plugin import: 'eslint-plugin-import'

node.jsreactjsnpmcreate-react-app

提问by Willjay

I'm new to react. I'm following the tutorial steps installing node. However, when I run npm start, errors keep show up.

我是新来的反应。我正在按照教程步骤安装节点。但是,当我运行时npm start,错误不断出现。

Failed to compile.

./src/index.js
Module build failed: Error: Failed to load plugin import: Cannot find module 'eslint-plugin-import'
Referenced from: 
at Array.forEach (native)
at Array.reduceRight (native)

Also, I tried to install 'eslint-plugin-import', but in vain...

另外,我尝试安装'eslint-plugin-import',但徒劳无功......

npm install eslint-plugin-import -g

npm WARN [email protected] requires a peer of [email protected] - 4.x but none was installed.

+ [email protected]

System info

系统信息

eslint --version
v4.2.0

npm -v
5.2.0

npm list -g | grep eslint
├─┬ [email protected]
│ ├─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
├─┬ [email protected]

回答by RussellB

The issue is resolved for me after installing the following in a row:

连续安装以下内容后,问题已为我解决:

npm install eslint-plugin-import eslint-plugin-flowtype eslint-plugin-jsx-a11y eslint-plugin-react

Have you tried installing eslint locally, like

您是否尝试过在本地安装 eslint,例如

npm install eslint-plugin-import --save-dev

?

?

Edit -Solution:

编辑 - 解决方案:

Instead of installing eslint packages one after another, the problem can be alleviated by

可以通过以下方式缓解问题,而不是一个接一个地安装 eslint 包

npm install react-scripts

as react-scripts is taking care of webpack, babel and eslint and the dependencies thereof.

因为 react-scripts 正在处理 webpack、babel 和 eslint 及其依赖项。

This may avoid conflicts, as in your case.

这可以避免冲突,就像您的情况一样。

回答by Ivan Fetsenets

Try this

尝试这个

npm install -g eslint

then

然后

eslint --init

回答by Robert Niestroj

Run today in the same problem. Had upgraded ESLint 5.16 to 6.6.0 and had been using the vue-eslint-plugin 5.2.3. Had to install this packages:

今天在同样的问题中运行。已经将 ESLint 5.16 升级到 6.6.0,并且一直在使用 vue-eslint-plugin 5.2.3。必须安装这个包:

npm install eslint-plugin-import --save-dev
npm install eslint-plugin-node --save-dev
npm install eslint-plugin-promise --save-dev
npm install eslint-plugin-standard --save-dev

回答by Rishi Raj

I experienced this while running create-react-appafter a successful npm install. Bringing down the npm version from v5.2 to v4.6.1 fixed this for me.

create-react-app在成功运行npm install. 将 npm 版本从 v5.2 降低到 v4.6.1 为我解决了这个问题。