-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Nodejs workspaces and imports issue #3174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are we sure it's a duplicate issue? And how will the typescript resolver fix a vanilla nodejs issue? |
Yes, pretty sure, the current built-in You can try https://github.com/import-js/eslint-import-resolver-typescript (also works for import { createNodeResolver } from 'eslint-plugin-import-x'
export default [
{
settings: {
'import-x/resolver-next': [createNodeResolver()],
},
},
] |
Thanks for the feedback, much appreciated! Those seem to resolve the issue, but I'm now getting:
when using the
|
Try to add By the way, you can combine the first config with |
Awesome, thanks @JounQin! That did the trick. Really appreciate it 👍 |
Reproduceable Examples
Code Sandbox Repo Explaining The Issue
ZIP File Containing A Copy Of The Code Sandbox Repo
Introduction
We've been struggling to get eslint-plugin-import to work in a monorepo using NPM workspaces and NPM imports
Setup
Our monorepo has the following structure:
The root
package.json
file looks like this:The
package-a
package.json
file looks like this:The
package-b
package.json
file looks like this:Issue description
When running
npm run start:package-a
from the root, the code executes correctly:This implies that the imports are resolving correctly and that code works.
The error comes in when running ESLint with the import plugin. The current ESLint config file currently looks like this:
When running ESLint, the following errors get raised:
package-a
makes use of Nodejs"imports"
to simplify imports within the project.1:25 error Unable to resolve path to module '#package-a/utils' import/no-unresolved
)package-b
makes use of Nodejs"workspaces"
to manage nested packages. It installspackage-a
as one of it's dependencies.1:9 error convert not found in '@package/a' import/named
)What we've tried
We've tried adding eslint-import-resolver-node:
We've tried adding
moduleDirectory
:We've tried using
import/external-module-folders
as explained here:Unfortunately, none of the above solutions worked. Hopefully there is just a simple config we're missing.
Any idea how these kinds of imports can be supported?
The text was updated successfully, but these errors were encountered: