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

Willjay picture Willjay · Jul 13, 2017 · Viewed 31.3k times · Source

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

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...

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]

Answer

Bussller picture Bussller · Jul 13, 2017

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

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

?

Edit -Solution:

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

npm install react-scripts

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

This may avoid conflicts, as in your case.