eslint-import-resolver-exports

raw JSON →
1.0.0-beta.5 verified Sat Apr 25 auth: no javascript

A resolver for eslint-plugin-import that supports the package.json#exports field, enabling proper resolution of package entry points when using the exports map. Version 1.0.0-beta.5 is the current stable version, with infrequent releases. Key differentiators: it integrates seamlessly with existing resolvers (like node or typescript) and only handles exports resolution, delegating other resolution to a primary resolver. It uses resolve.exports under the hood.

error Module not found: Can't resolve 'some-package' in 'some/file'
cause exports resolver not configured or missing; the resolver doesn't fallback to node resolution.
fix
Add another resolver (e.g., node) to settings['import/resolver'].
error Unable to resolve path to module 'some-package'.
cause The package's exports field may not include the subpath you're trying to import.
fix
Check the package's exports map; add fallback resolver or use a different import path.
gotcha This resolver only handles package.json#exports, not other Node resolution features. Always include another resolver (e.g., node or typescript).
fix Add an additional resolver like 'node' in the settings.
deprecated Package is in beta; API may change.
fix Pin version to beta.5 or watch for breaking changes.
gotcha Options are passed to resolve.exports; incorrect options may cause resolution failures.
fix Refer to resolve.exports documentation for valid options.
npm install eslint-import-resolver-exports
yarn add eslint-import-resolver-exports
pnpm add eslint-import-resolver-exports

Basic ESLint configuration to resolve package exports using both node and exports resolvers.

// .eslintrc.js
module.exports = {
  extends: ['plugin:import/recommended'],
  plugins: ['import'],
  settings: {
    'import/resolver': {
      node: {},
      exports: {
        // Options go here
        conditions: ['node', 'import'],
      },
    },
  },
  rules: {
    'import/no-unresolved': 'error',
  },
};