Eslint-plugin-import: Unable to load resolver when using custom webpack config file name

Created on 3 Jul 2017  路  5Comments  路  Source: benmosher/eslint-plugin-import

If I use

  "settings": {
    "import/resolver": "webpack"
  }

as my settings and my webpack config file is webpack.config.js everything works.

But if I try to do

  "settings": {
    "import/resolver": {
      "config": "webpack.config.dev.js"
    }
  }

and rename my webpack config file name to webpack.config.dev.js.

I get this error when I'm linting

Resolve error: unable to load resolver "config"

I'm using

  • webpack 2.6.1
  • eslint-plugin-import 2.6.0
  • eslint-import-resolver-webpack 0.8.3

Most helpful comment

you need to wrap it within the webpack object 馃槃

"settings": {
    "import/resolver": {
      "webpack": {
        "config": "./webpack.config.web.dev.js"
      }
    }
  }

All 5 comments

What if the path starts with ./? node's require algorithm requires all relative paths start with a dot.

Doesn't work either.

Similarly, mine fails if my webpack config is in a subdirectory, such as ./config/webpack.config.js. An error is thrown before linting occurs _(paths anonymized below)_:

Error: Cannot find module '.../node_modules/.../some-depenency/config/webpack.config.common.js'

you need to wrap it within the webpack object 馃槃

"settings": {
    "import/resolver": {
      "webpack": {
        "config": "./webpack.config.web.dev.js"
      }
    }
  }

This solved it! I missed that. Thanks @kossel.

Was this page helpful?
0 / 5 - 0 ratings