javascript: Cannot find module 'eslint-plugin-import'

I’ve been encountering this issue while trying to setup eslint with airbnb. Using this npx package. https://www.npmjs.com/package/eslint-config-airbnb-base

ESlint output

Failed to load plugin 'import' declared in 'server\.eslintrc.js » eslint-config-airbnb-base » Z:\Development\JS\Nuxt-Test-App\zuka-ma-shlong\server\node_modules\eslint-config-airbnb-base\rules\imports.js': Cannot find module 'eslint-plugin-import'

package.json

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.5",
    "eslint": "6.1.0",
    "eslint-config-airbnb-base": "14.0.0",
    "eslint-plugin-import": "^2.18.2",
    "express": "^4.17.1"
  }
}

.eslintrc.js

module.exports = {
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true,
  },
  extends: [
    'airbnb-base',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parserOptions: {
    ecmaVersion: 2018,
  },
  rules: {
  },
};

eslint-plugin-import is however installed locally aswell as eslint.

I’ve attempted installing the package with yarn which also didn’t seem to work either. Issue link

At this point I’ve ran out of ideas to get this working.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24

Most upvoted comments

I was using eslint outside of the root directory of the project where eslint was placed/installed. Thank you for following up.

@joelb01-github thank you!! Wrestled with this for quite some time. Cleaning out my ESLint config finally resolved it.

@Rotinx thanks for coming back to me 😃

I ended up making it work; in my case my .eslintrc had a wrong syntax - the error was quite misleading tho…

Hey @joelb01-github, unfortunately I can not entirely recall. I realise now looking back my explanation is terrible sorry about that. I believe it was due to me having ealint installed twice within the same directory.

/ (Installed here) /Frontend (also installed here)

Though I’m not sure if that’s the solution sorry. I would throw the project your having a issue with into a separate folder outside of the root project folder to test if it works outside of it.