You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I try to run the script src/index.ts, it results in this error
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/chen/development/relatrack-backend/src/index.ts
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
at defaultLoad (node:internal/modules/esm/load:141:22)
at async nextLoad (node:internal/modules/esm/hooks:865:22)
at async nextLoad (node:internal/modules/esm/hooks:865:22)
at async Hooks.load (node:internal/modules/esm/hooks:448:20)
at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
But if I run the script with script/index.js, I get this error
node:internal/modules/cjs/loader:1147
throw err;
^
Error: Cannot find module './index.js'
Require stack:
- /home/chen/development/relatrack-backend/src/imaginaryUncacheableRequireResolveScript
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Function.resolve (node:internal/modules/helpers:187:19)
at requireResolveNonCached (/home/chen/development/relatrack-backend/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ts-node/dist/bin.js:550:16)
at getProjectSearchDir (/home/chen/development/relatrack-backend/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ts-node/dist/bin.js:519:40)
at phase3 (/home/chen/development/relatrack-backend/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ts-node/dist/bin.js:267:27)
at bootstrap (/home/chen/development/relatrack-backend/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ts-node/dist/bin.js:47:30)
at main (/home/chen/development/relatrack-backend/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ts-node/dist/bin.js:33:12)
at Object.<anonymous> (/home/chen/development/relatrack-backend/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ts-node/dist/bin.js:580:5)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/chen/development/relatrack-backend/src/imaginaryUncacheableRequireResolveScript'
]
}
Node.js v20.10.0
No where am I importing "imaginaryUncacheableRequireResolveScript" and looking that up on Google yields nothing.
Expected Behavior
It runs my code with either of the file extensions I provide
Actual Behavior
The errors above.
Steps to reproduce the problem
running pnpm/npm ts-node src/index.js with my tsconfig (making sure tpye is set to module in package.json)
flleeppyy
changed the title
Cannot find module './index.js' and requiring "imaginaryUncacheableRequireResolveScript"
ESM: Cannot find module './index.js' and requiring "imaginaryUncacheableRequireResolveScript"
Dec 19, 2023
FWIW - I ran into this issue just now and after banging my head against the wall for about 30 minutes, I realized the file I was calling fell under a pattern in my .gitignore file so it wasn't pulling into the build server I was running on. Dumb mistake on my part but my be an easy issue to overlook.
Search Terms
If I try to run the script src/index.ts, it results in this error
But if I run the script with script/index.js, I get this error
No where am I importing "imaginaryUncacheableRequireResolveScript" and looking that up on Google yields nothing.
Expected Behavior
It runs my code with either of the file extensions I provide
Actual Behavior
The errors above.
Steps to reproduce the problem
running pnpm/npm ts-node src/index.js with my tsconfig (making sure tpye is set to module in package.json)
Minimal reproduction
https://github.com/flleeppyy/ts-node-repros
TypeStrong/ts-node-repros#37
Specifications
ts-node v10.9.2
node v20.10.0
compiler v5.3.3
The text was updated successfully, but these errors were encountered: