I have the following situation:
I need to have
"type": "module"in mypackage.json(ok)I have a
.tsxfile that I need to execute as a script. Eg:yarn myScript(ok)Windows OS (ok)
Node 14.17 (ok)
The problem is that it seems to be harder than it looks.
I have tried the following:
Running with
ts-nodeproduced:Error: Unknown file extension ".tsx"Running with
node --loader ts-node/esmproduced:Error: const err = new ERR_UNSUPPORTED_DIR_IMPORT(path, fileURLToPath(base));Defining
"esModuleInterop": trueintsConfigresulted in nothing being changed.Trying to transpile with babel and then run node produced:
Error: require is not definedTrying to transpile with typescript resulted in many
node_moduleserrors.
Does anyone have any idea or suggestions?