Skip to content

"moduleResolution": "NodeNext" throws ESM related errors #50058

Open
@sagargurtu

Description

@sagargurtu

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.69.2
  • OS Version: macOS 12.4
  • TypeScript Version: 4.7.4

Steps to Reproduce:

{
  "compilerOptions": {
    "target": "esnext",
    "lib": ["dom", "esnext"],
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "module": "NodeNext",
    "moduleResolution": "NodeNext"
  },
  "include": ["./src/**/*"]
}
  • Add "type": "module" in package.json
  • Following error messages are displayed by VSCode in a file with .ts extension under src/:
// Cannot find module 'pretty-ms' or its corresponding type declarations. ts(2307)
import ms from "pretty-ms";

// The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. ts(1470)
console.log(import.meta.url);
  • tsc throws no errors.
  • Change below values intsconfig.json
{
  "module": "esnext",
  "moduleResolution": "node"
}
  • VSCode no longer throws any errors.

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions