-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ESM: Unable to resolve path to module 'got' import/no-unresolved #2331
Comments
Do you have it installed? Are you getting that warning on the command line, or just in your editor? Is eslint installed locally, and not globally? |
"dependencies": {
"got": "^12.0.0"
},
"devDependencies": {
"@babel/core": "^7.16.5",
"@babel/eslint-parser": "^7.16.5",
"eslint": "^8.5.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.3"
},
"eslintConfig": {
"parser": "@babel/eslint-parser",
"extends": [
"airbnb-base"
],
"parserOptions": {
"ecmaVersion": 2021,
"requireConfigFile": false
}
} |
Thanks, but that doesn’t answer my questions. Resolving requires everything be present in node_modules. |
Yes
Comandline and editor (vs code).
Locally, fresh install. |
Thanks! In this case, the latest version of got drops support for CJS, and as such, can’t be resolved by our CJS-only resolution mechanism. If you’re using native ESM, this plugin won’t help you, because it’s designed for use with CJS, or transpiled ESM (Babel/TS). If you downgrade to got v11, or switch to a package author that isn’t user-hostile, then you should see everything resolve correctly. |
ESM should work. CJS should be deprecated. |
That’s a strong and wildly incorrect opinion. Native ESM has tons of downsides and offers no benefits over CJS. Both are first-class module systems in node, so yes, native ESM should work, but the ecosystem isn’t ready to support it yet. I’m going to close this. |
Same issue with import {Except} from 'type-fest';
|
Same problem, caused by the same maintainer - altho in that case, it doesn't have any runtime values, so you should be using |
Those modules that the |
@jsg2021 yes, see #2331 (comment) |
@ljharb sorry :} I was just deep in my own research trying to assist my finding. Forgot to double-check the thread. I've been lucky that I'm only now having to sort with these modules. |
I made a repro for this issue: https://github.com/silverwind/import-got git clone https://github.com/silverwind/import-got.git
cd import-got
npm i && npm t It seems there is a unresolvable situation where the package authors indirectly blames this module:
But #2331 (comment) blames the module, so we come full cycle. Is there any resolution in sight? Maybe @szmarczak can comment what the problem is with |
that comment answered your question? Pure esm packages do not need this rule. Turn it off? |
I'm pretty sure (Meanwhile, I managed to remove my |
idk, but inspecting |
Just guessing, but maybe it's because |
yep. commonjs algo falls back to index.js at the root of no entry point is found in package.json |
So it's still related to |
Yes, ultimately, the issue is that Interestingly, > require.resolve("got")
'/Users/silverwind/git/import-got/node_modules/got/dist/source/index.js' Maybe |
Again, ESM-only packages are the problem - this plugin supports transpiled ESM, and not native ESM. is-ip seems to work because the index.js and lack of main means pre-exports node would try and fail to load that file. When While this support is quite overdue here, ESM-only packages remain exceedingly user-hostile, and i strongly suggest aggressively avoiding them. There’s always an alternative non-ESM-only (and thus better) package to choose. |
For some cases like a default import, it might be enough to just see if the request resolves to a file, without actually parsing it. I'm pretty sure there is some bug in resolve.js where the code path does not end up in |
It is a very explicit and intentional choice to avoid using the built-in require.resolve. |
This rule does not work with esm-only packages, and [it doesn't look like it ever will](import-js/eslint-plugin-import#2331). We'll remove it for now and rely on coverage in our tests for now
This rule does not work with esm-only packages, and [it doesn't look like it ever will](import-js/eslint-plugin-import#2331). We'll remove it for now and rely on coverage in our tests for now
Unable to resolve path to module 'got' import/no-unresolved
The text was updated successfully, but these errors were encountered: