create-react-app: npm start gives "Module build failed: Error: Failed to load plugin import: Cannot find module 'eslint-plugin-import'"

Is this a bug report?

Yes, seems like it to me.

Can you also reproduce the problem with npm 4.x?

I haven’t tried yet. I think that would be a wild goose chase. This problem just started today out of the blue. My hunch is that is an environment problem of some sort.

Which terms did you search for in User Guide?

I did a google search instead. Found no help.

Environment

  1. node -v: v8.1.2
  2. npm -v: 5.2.0
  3. yarn --version (if you use Yarn): don’t use
  4. npm ls react-scripts (if you haven’t ejected): react-scripts@1.0.10

Then, specify:

  1. Operating system: macOS 10.12.5
  2. Browser and version (if relevant): Chrome Version 59.0.3071.115 (Official Build) (64-bit)

Steps to Reproduce

(Write your steps here:)

Invoke:

  1. create-react-app my-app (no issues here)
  2. cd my-app
  3. npm start

After step #3 the console window shows:

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)

Expected Behavior

(Write what you thought would happen.)

Actual Behavior

(Write what happened. Please add screenshots!)

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 16
  • Comments: 17 (8 by maintainers)

Most upvoted comments

I had same issue. Installing manually following modules was a fix for me:

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

Upgrading to npm@5.3.0 solves the problem.

@tenzan thanks for the full list of plugins that npm 5.2 finds missing. One thing to bear in mind is that eslint-plugin-jsx-a11y should be v5 instead of the latest (v6); otherwise each file creates a warning:

npm start

Compiled with warnings.

./src/index.js
  Line 1:  Definition for rule 'jsx-a11y/href-no-hash' was not found  jsx-a11y/href-no-hash

./src/registerServiceWorker.js
  Line 11:  Definition for rule 'jsx-a11y/href-no-hash' was not found  jsx-a11y/href-no-hash

./src/App.js

  Line 1:  Definition for rule 'jsx-a11y/href-no-hash' was not found  jsx-a11y/href-no-hash

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

Here’s a one-liner hack that temporary helped me npm start without downgrading npm to v4:

npm install --save-dev eslint-plugin-import eslint-plugin-react eslint-plugin-flowtype eslint-plugin-jsx-a11y@5

All worked for me after upgrading to npm 5.3. Can anyone else confirm please?

Switching back to npm@4.6.1 solved the issue for me.

The following is working fine:

$ npx create-react-app test-eslint
$ cd test-eslint/
$ yarn start
$ npm -v
5.2.0
$ node -v
v8.1.4

This means it’s an NPM bug or an environment bug. Either way, you should try NPM 4 like suggested as NPM 5 is very buggy.

If you can tell us how or why your environment is unique, we may be able to help. But this is not a bug on our end.

Upgrade to npm v5.3.0 didin’t work for me, I had to switch to yarn

I’ve commented on reddit, @NathanCH. Thanks for the heads up.