eslint-plugin-import: Core module subpaths are not supported
Trying to use import modules that specify a subpath aren’t supported and I haven’t been able to find a way to work around it.
Error:
Unable to resolve path to module ‘path/posix’. eslint(import/no-unresolved)
Example:
import { join, parse, relative } from 'path/posix';
import { readFile, writeFile } from 'fs/promises';
I tried the following with this plugin to no avail:
"rules": {
"import/no-unresolved": ["error", {
"ignore": ["path/posix", "path\/posix", "path\\/posix"]
}],
},
"settings": {
"import/core-modules": ["path/posix", "path\/posix", "path\\/posix"]
}
Similarly, this problem exists with node/no-missing-import
but I can use the following workaround:
"node/no-missing-import": ["error", {
"allowModules": ["path/posix"]
}]
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25 (10 by maintainers)
For anyone that finds this still. VSCode still ships with v12 Node where fs/promises is not available.
You can solve this by adding the following VSCode setting, to use your system node.
https://github.com/microsoft/vscode-eslint/issues/1097
@ljharb I am getting it both in the terminal running
eslint
as well as in VS Code. Let me try to track down what the real fault is then.@ljharb Here you go: