question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Core module subpaths are not supported

See original GitHub issue

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"] 
}]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
nosvaldscommented, Mar 31, 2021

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.

{
     "eslint.runtime": "node"
}

https://github.com/microsoft/vscode-eslint/issues/1097

1reaction
thernstigcommented, Feb 23, 2021

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues - GitHub
When migrating to cdk 2.1.0, i have the following error: Error: Package subpath './core' is not defined by "exports" in /.
Read more >
Ask Question - Stack Overflow
I was receiving Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in ...
Read more >
Modules: Packages | Node.js v19.3.0 Documentation
When the "exports" field is defined, all subpaths of the package are encapsulated and no longer available to importers. For example, require('pkg/subpath.js') ...
Read more >
Dependency resolution - Parcel
As Parcel builds your source code, it discovers dependencies, which allow code to be broken into separate files and reused in multiple places....
Read more >
How Jotai Specifies Package Entry Points - Daishi Kato's blog
With “exports”, we can export subpath entry points along with main entry point. We want to support both CJS and ESM, and conditional...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found