Next.js app with absolute path - getting eslint "Unable to resolve path to module" error
See original GitHub issueHello,
I’m wondering what I’ve done wrong because in a really simple use case i’m still getting the “Unable to resolve path to module” error. Here is my configuration:
"eslint-plugin-import": "^2.23.3",
"eslint-import-resolver-alias": "^1.1.2",
My folders:
project/src/components
project/src/styles
project/src/utils
project/jsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": [
"src/components/*"
],
"@utils/*": [
"src/utils/*"
],
"@styles/*": [
"src/styles/*"
]
}
}
}
project/.eslintrc.js
settings: {
'import/resolver': {
alias: [
['@components', './src/components'],
['@styles', './src/styles'],
['@utils', './src/utils'],
],
},
},
I’m using the import like this import Layout from '@components/Layout';
The Next.js compilation is working great but eslint doesn’t seems to use import/resolver settings. Any ideas?
Thanks.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
Using eslint with typescript - Unable to resolve path to module
As soon as I compile the .ts file to a .js, the error goes away. However, since eslint is supposed to work with...
Read more >ESLint: Unable to resolve path to module #1180 - GitHub
We have solution for absolute path, like this: import MyComponent from 'src/components/MyComponent' It is work fine for yarn start, ...
Read more >Unable to resolve path to module 'next/app'.eslint : r/nextjs
Unable to resolve path to module 'next/app'.eslint. &. Resolve error: ENOENT: no such file or directory, stat './tsconfig.json'. Any ideas why?
Read more >ESLint Unable to resolve path to module
Error Message: (ESLint) import/no-unresolved Unable to resolve path to module '@project/components/ThemeProviders' Active.
Read more >"Unable to resolve path to module" while the path exist-Reactjs
Coding example for the question Sublime eslint plugin: "Unable to resolve path to module" while the path exist-Reactjs.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried creating a repo which replicates the issue and found why it wasn’t working. If you are extending eslint configuration with the
extends
option, you need to addplugin:import/resolver
in the list..eslintrc.js
Thank you for your help @PsyGik.
Thanks @ravenbasix This should be added to the wiki!