eslint-import-resolver-typescript
eslint-import-resolver-typescript copied to clipboard
import/no-unresolved: wildcard exports causing import resolution error in a monorepo
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