Using eslint with typescript - Unable to resolve path to module
I had the same problem and I was only able to fix it by adding the typescript plugin to .eslintrc
, using the extends
option in .eslintrc
extends: [
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
],
This does it for me:
.eslintrc.js
{
...
settings: {
...
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
moduleDirectory: ['node_modules', 'src/'],
},
},
}
}
You can set the ESLint module import resolution by adding this snippet to your .eslintrc.json
configuration file:
{
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
...
}
More informations about resolvers: https://github.com/benmosher/eslint-plugin-import#resolvers.