Skip to content

ESMLoader with Node/ts-node launched via VS Code #1741

Description

@JCropsey-Clearwave

When I try to run Node with ts-node via VS Code, I get the following error despite its having worked previously with the same configuration:
TypeError: Invalid module "file:///C:/Projects/CW-Port0/infra/azure/src/create-resources.ts"
at new NodeError (node:internal/errors:371:5)
at ESMLoader.load (node:internal/modules/esm/loader:380:13)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:47)
at link (node:internal/modules/esm/module_job:70:21)

create-resources.ts is the main file for the project.
Possibly related to #1636.

launch.json:
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "runtimeArgs": [ //"-r", "ts-node/register", "--experimental-specifier-resolution=node", "--loader", "ts-node/esm" ], "args": [ "${workspaceFolder}/src/create-resources.ts", "--" ], "debug.javascript.terminalOptions": { "skipFiles": [ "<node_internals>/**" ] }, } ] }

tsconfig.json:
{ "compilerOptions": { "module": "esnext", "target": "es2018", "moduleResolution": "node", "esModuleInterop": true, "noEmit": true, "noImplicitAny": true, "outDir": "dist", "removeComments": false, "preserveConstEnums": true, "sourceMap": true, "lib":[ "DOM" ], // "dom.iterable" "types": [ "node", ] }, "ts-node": { "skipIgnore": false }, "include": [ "./src/*" ], "exclude": [ "node_modules", "./*.spec.ts", "./src/*.spec.ts" ] }

Activity

  1. cspotcode commented on May 5, 2022

    @cspotcode
    Collaborator

    We request additional information in our bug report template that has been omitted here. I'll convert this to a discussion so the community can solicit the additional information.

  2. locked and limited conversation to collaborators on May 5, 2022
  3. converted this issue into a discussion #1743 on May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions