[Running] ts-node "/Users/easy/Documents/Harmony/Project/Hello.ts"
TypeError: Unknown file extension ".ts" for /Users/easy/Documents/Harmony/Project/Hello.ts
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:218:9)
at defaultGetFormat (node:internal/modules/esm/get_format:244:36)
at defaultLoad (node:internal/modules/esm/load:122:22)
at async ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:479:32)
at async ModuleJob._link (node:internal/modules/esm/module_job:112:19) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
在当前目录新增配置文件 tsconfig.json 解决
企业微信截图_37f0537d-bef1-4079-9964-0234d1771092.png{
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
}
}
网友评论