eslint-import-resolver-next
raw JSON → 0.6.0 verified Sat Apr 25 auth: no javascript
An ESLint resolver plugin for eslint-plugin-import and eslint-plugin-import-x that resolves modules using unrs-resolver (previously oxc-resolver). v0.6.0 migrated from oxc-resolver to unrs-resolver. Supports monorepos, pnpm workspaces, and TypeScript/JavaScript path aliases from tsconfig/jsconfig. Provides a modern alternative to eslint-import-resolver-typescript and eslint-import-resolver-node, with faster resolution and built-in caching control via NEXT_RESOLVER_CACHE_DISABLED environment variable. Publish cadence is irregular but with breaking changes between versions.
Common errors
error Error: ESLint couldn't find the resolver "next". Did you install it? ↓
cause The resolver is not installed or is not a direct dependency of the project.
fix
Run npm install -D eslint-import-resolver-next and ensure it's in devDependencies.
error Cannot find module 'eslint-import-resolver-next' ↓
cause Package not installed or ESLint is running in a monorepo context where the resolved path doesn't include the dependency.
fix
Install the package in the root or use eslint's resolve plugin configuration to point to the correct location.
error TypeError: createNextImportResolver is not a function ↓
cause Using createNextImportResolver on a version earlier than v0.5.0, or importing incorrectly.
fix
Update to v0.5.0+ and ensure correct import: const { createNextImportResolver } = require('eslint-import-resolver-next');
Warnings
breaking v0.5.0 renamed NewResolver to NextImportResolver and requires Node >=14.18.0. ↓
fix Update imports: use NextImportResolver instead of NewResolver. Ensure Node version >=14.18.0.
breaking v0.6.0 migrated from oxc-resolver to unrs-resolver. Options that were specific to oxc-resolver may not be supported. ↓
fix Review unrs-resolver documentation for valid options. Remove any oxc-resolver-specific options.
gotcha The 'alias' option resolves relative paths from the package directory, not from the source file. This can cause unexpected resolution failures. ↓
fix Use absolute paths or ensure relative paths are relative to the package root. Use path.resolve(__dirname, ...) if needed.
gotcha Cache can be disabled by setting NEXT_RESOLVER_CACHE_DISABLED=true, but this is not well documented. Inadvertent cache hits can cause stale resolutions. ↓
fix If encountering stale resolutions, set environment variable NEXT_RESOLVER_CACHE_DISABLED=1 or clear node_modules/.cache.
Install
npm install eslint-import-resolver-next yarn add eslint-import-resolver-next pnpm add eslint-import-resolver-next Imports
- default (resolver object) wrong
const resolver = require('eslint-import-resolver-next').defaultcorrectsettings: { 'import/resolver': { next: { /* options */ } } } - createNextImportResolver wrong
const { createNextImportResolver } = require('eslint-import-resolver-next').default;correctconst { createNextImportResolver } = require('eslint-import-resolver-next'); - NextImportResolver wrong
import NextImportResolver from 'eslint-import-resolver-next';correctimport { NextImportResolver } from 'eslint-import-resolver-next';
Quickstart
// Install: npm install -D eslint-import-resolver-next eslint-plugin-import
// .eslintrc.js
module.exports = {
plugins: ['import'],
settings: {
'import/resolver': {
next: {
tsconfig: true,
jsconfig: true,
alias: {
'@': './src'
},
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
roots: [process.cwd()]
}
}
},
rules: {
'import/no-unresolved': 'error',
'import/named': 'error'
}
};