Ts-node module resolution is not respected #1859
lantos1618
started this conversation in
General
Replies: 2 comments 8 replies
-
I double-checked the docs, looks like moduleTypes might be configured incorrectly: |
Beta Was this translation helpful? Give feedback.
0 replies
-
Just updated to cjs still same response |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Search Terms
ts-node module type resolution package.json
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /...
Expected Behavior
when "moduleType" is specified in ts-config.json it should ignore the "type": "module" specified in package.json
tsconfig.json
package.json
Actual Behavior
"type": "module", is respected when tsconfig.json should be respected.
Even passing "NODE_OPTIONS='--import-type=commonjs'" does not get respected.
throws
Steps to reproduce the problem
npm init
npm install typescript ts-node @types/node
tsc --init
create a src/index.ts with console.log("hello") inside
add "type": "module" to package.json
add "start": "ts-node src/index.ts" to package.json
npm start
Minimal reproduction
I have an example here.
https://github.com/lantos-lgtm/typescript-incorrect-behaviour
git clone https://github.com/lantos-lgtm/typescript-incorrect-behaviour cd typescript-incorrect-behaviour npm install npm start
Specifications
ts-node v10.9.1
node v16.16.0
compiler v4.7.4
Beta Was this translation helpful? Give feedback.
All reactions