ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

Cannot run mts and ts files with ESM syntax

Open wbxl2000 opened this issue 1 year ago • 2 comments

Search Terms

  • https://github.com/TypeStrong/ts-node/issues/935

Expected Behavior

print '???' in terminal

Actual Behavior

image

Steps to reproduce the problem

  1. pnpm i
  2. pnpm start

Minimal reproduction

https://github.com/wbxl2000/ts-esm-test

Specifications

  • ts-node version: v10.9.1
  • node version: v20.2.0
  • TypeScript version: v5.1.6
  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "module": "ESNext" // or ES2015, ES2020
  },
  "ts-node": {
    // Tell ts-node CLI to install the --loader automatically, explained below
    "esm": true
  }
}
  • package.json:
{
  "name": "ts-node-test",
  "version": "1.0.0",
  "description": "",
  "type": "module",
  "scripts": {
    "start": "ts-node ./test.ts"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "ts-node": "^10.9.1",
    "typescript": "^5.1.6"
  }
}
  • Operating system and version: macOS 13.5 (22G74)
image
  • If Windows, are you using WSL or WSL2?:

Minimal reproduction

same to above

Specifications

  • ts-node version:
  • node version:
  • TypeScript version:
  • tsconfig.json, if you're using one:
{}
  • package.json:
{}
  • Operating systion:
  • If Windows, are you using WSL or WSL2?:

wbxl2000 avatar Aug 16 '23 04:08 wbxl2000

After switching to nodejs 16, I was able to execute it normally. But why is that?

wbxl2000 avatar Aug 16 '23 08:08 wbxl2000

Seems to be duplicated with #1997

jameslan avatar Aug 23 '23 19:08 jameslan