Skip to content

import/no-unresolved: wildcard exports causing import resolution error in a monorepo #218

Closed as not planned
@davbrito

Description

@davbrito

In my monorepo, I have a package.json file with the following configuration:

{
  "name": "example",
  "private": "true",
  "type": "module",
  "version": "1.0.0",
  "description": "",
  "devDependencies": {},
  "scripts": {},
  "exports": {
    "./*.ts": "./src/*.ts"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

However, when I try to import a module from this package in my code with the statement import { example } from "example/index.ts", I encounter the following error:

error: Unable to resolve path to module 'example/index.ts' (import/no-unresolved) at src/index.ts:1:25:
> 1 | import { example } from "example/index.ts";
    |                         ^
  2 | 
  3 | example();
  4 | 

This is my .eslintrc

{
  "extends": ["plugin:import/recommended", "plugin:import/typescript"],
  "parser": "@typescript-eslint/parser",
  "plugins": ["import"],
  "rules": {
    "import/no-unresolved": "error"
  },
  "settings": {
    "import/resolver": {
      "node": true,
      "typescript": true
    }
  }
}

Here is a demo CodeSandbox that reproduces the error: https://codesandbox.io/p/sandbox/amazing-booth-i2ugum?welcome=true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions