eslint-plugin-import: [no-unresolved]: Unable to resolve path to module with node: protocol specifier
Hi there, thanks for this plugin, super useful! š
Ran into an issue when using the new node:
prefix for builtin / core modules (currently in v16, but will be backported): import/no-unresolved
cannot resolve the path to the module:
import fs from 'node:fs';
~~~~~~~
^---- Unable to resolve path to module 'node:fs' eslint(import/no-unresolved)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 35 (23 by maintainers)
Commits related to this issue
- Add ESLint Node.js runtime config To avoid issues like this: https://github.com/benmosher/eslint-plugin-import/issues/2031#issuecomment-826160498 — committed to upleveled/system-setup by karlhorky 3 years ago
- Add ESLint Node.js runtime config To avoid issues like this: https://github.com/benmosher/eslint-plugin-import/issues/2031#issuecomment-826160498 — committed to gruvector/system-setup by gruvector 3 years ago
Ah yeah, in VSCode ESLint extension, itās still using Node 12:
But on the command line, all is good! š
If itās a monorepo, you may have a central
yarn.lock
orpackage-lock.json
file that contains the older versions ofis-core-module
, which you may be able to manually upgrade - for example, upgrading a version inyarn.lock
by hand like this: https://www.youtube.com/watch?v=iOYTpHRzL0ABad news, I couldnāt reproduce the error with a minimal setup. My current ESLint config has a lot more plugins, configs and overrides than the example I was trying to set up, which seems to work great despite having exactly the same Node and package versions (I verified them manually in the lockfile and in my
node_modules
).I donāt really know what could make the rule fail in my current full-size setup, which is configured exactly the same, regarding the import plugin at least š I absolutely canāt downsize my current project bit by bit, because itās a huge monorepo with 30+ packages where ESLint was completely absent, so removing each piece to try the rule again would take forever.
Iāll put this on the side for a while since I canāt afford to spend much more time on this. Thanks for your help anyway @ljharb and for your reactivity, Iāll ping you someday if I ever figure it out!
Sure, Iāll continue this tomorrow and keep you updated. Thanks for your help!
@karlhorky I tried it and āeslint.runtimeā: āC:\Program Files\nodejs\node.exeā but both didnāt work. Iāll take @ljharb advice and not even use it since there isnāt any benefit.
@TriStarGod youāre probably looking for the following setting in your VS Code
settings.json
(this enables your system version of Node.js):Iād suggest keeping that rule off anyways; the advantage to using
node:
is close to zero, and the downsides are huge (because it hurts backwards compatibility)Thanks for clarifying the situation! I reverted to the traditional imports and turned off
unicorn/prefer-node-protocol
.Support for
node:
was backported to Node v14.13.1 and v12.20.0: https://nodejs.org/api/esm.html#esm_node_importsis-core-module v2.3.0 has been released, which should address the problem.
Indeed; the new protocol support isnāt added to
resolve
yet. Please file an issue there; Iāll get to it as soon as i can.