Comments (17)
Workaround: You can use node --loader ts-node/esm file.ts
instead of ts-node --esm file.ts
(which causes a ExperimentalWarning: --experimental-loader may be removed in the future
). It would be great if ts-node
provided an entrypoint that calls register
from node:module
, which seems to be Node's preferred way of registering loaders, now.
from ts-node.
Same issue in node v20.10.0
(current LTS)
from ts-node.
@michael42 thanks for the suggestion. This indeed works with both Node.js 18.18.2
and 18.19.0
.
I will, however, hold back with applying that change for now, as this would require changes across a dozen or so repos. We've simply pinned Node.js to 18.18.2
for now to unblock us.
I still consider this to be a bug in ts-node
.
from ts-node.
See #1997 - this sounds like a duplicate of that one.
I agree that #1997 and this one probably share the same root cause.
Yet, I think they differ in their implication: If ts-node
changed the way it works on a major version bump of Node.js, I'd say that's acceptable. But if ts-node
suddenly stopped working on a minor version bump of Node.js, I'd say it's a bug.
from ts-node.
Workaround: You can use
node --loader ts-node/esm file.ts
instead ofts-node --esm file.ts
(which causes aExperimentalWarning: --experimental-loader may be removed in the future
). It would be great ifts-node
provided an entrypoint that callsregister
fromnode:module
, which seems to be Node's preferred way of registering loaders, now.
This does not seem to work for me:
node --loader ts-node/esm -r tsconfig-paths/register ./scripts/deploy.ts
(node:129) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
/builds/ci-vct-dev/aws-platform-ci/aws-cdk/scripts/deploy.ts:1
import { AWS_DOMAIN } from '../shared-lib/src/environment/compile';
^^^^^^
from ts-node.
Does anyone know which version of node it works on ? Currently have this issue with node 20, running ts-node --esm in a module
@rreeves8 it works on Node.js 18.18.2. To my knowledge, any newer version runs into the problem described here (incl. Node.js 20). For following this kind of problem for Node.js 20, you may want to take a look at #1997 as well.
from ts-node.
node --loader ts-node/esm index.ts
works for me
from ts-node.
See #1997 - this sounds like a duplicate of that one.
from ts-node.
I'm using tsx with AWS CDK until this is resolved.
In cdk.json, change the app property to:
"app": "npx tsx bin/app.ts",
from ts-node.
Workaround: You can use
node --loader ts-node/esm file.ts
instead ofts-node --esm file.ts
(which causes aExperimentalWarning: --experimental-loader may be removed in the future
). It would be great ifts-node
provided an entrypoint that callsregister
fromnode:module
, which seems to be Node's preferred way of registering loaders, now.This does not seem to work for me:
node --loader ts-node/esm -r tsconfig-paths/register ./scripts/deploy.ts
(node:129) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`: --import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));' (Use `node --trace-warnings ...` to show where the warning was created) /builds/ci-vct-dev/aws-platform-ci/aws-cdk/scripts/deploy.ts:1 import { AWS_DOMAIN } from '../shared-lib/src/environment/compile'; ^^^^^^
Make sure you have "type": "module"
in package.json or rename the file to file.mts
from ts-node.
Same issue in node
v20.10.0
(current LTS)
@jetwiwo right, thanks for mentioning that. FWIW, it looks like it doesn't work with Node.js 20 at all. I've added Node.js 20 versions to the repo for reproducing the problem.
https://github.com/mlenkeit/ts-node-repro/actions/runs/7125070507
from ts-node.
Got bit by this just a few minutes ago as well, would agree with not expecting breaking changes with minor version bumps.
from ts-node.
Does anyone know which version of node it works on ? Currently have this issue with node 20, running ts-node --esm in a module
from ts-node.
Workaround: You can use
node --loader ts-node/esm file.ts
instead ofts-node --esm file.ts
(which causes aExperimentalWarning: --experimental-loader may be removed in the future
). It would be great ifts-node
provided an entrypoint that callsregister
fromnode:module
, which seems to be Node's preferred way of registering loaders, now.This does not seem to work for me:
node --loader ts-node/esm -r tsconfig-paths/register ./scripts/deploy.ts
(node:129) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`: --import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));' (Use `node --trace-warnings ...` to show where the warning was created) /builds/ci-vct-dev/aws-platform-ci/aws-cdk/scripts/deploy.ts:1 import { AWS_DOMAIN } from '../shared-lib/src/environment/compile'; ^^^^^^
Make sure you have
"type": "module"
in package.json or rename the file tofile.mts
thanks, it works for me
from ts-node.
FWIW, we have decided to switch to tsx
, given that there hasn't been any reaction yet from the maintainers of ts-node
.
In addition to replacing the dependency itself, we have removed the ts-node
config from our tsconfig.json
file and also uninstalled any explicit dependencies to swc
(if present), as it seems to be the default in tsx
.
We struggled a bit to make it work across Node.js versions, given that the --loader
and --import
options seem to be mutually exclusive, and ended up having dedicated scripts in our package.json
.
from ts-node.
Related Issues (20)
- not even the most simple use-case HOT 3
- console.log('hi'); fails in REPL with "module": "esnext" HOT 1
- UnhandledPromiseRejection: ts-node-esm does not display type checking results HOT 6
- ts-node doesn't run ESM modules as expected, either refusing`import` statements in ts file or not being able to run `.ts` files HOT 6
- In REPL, can't access the previous line's return value via `_`
- Error when using ts-node with tsonfig/bases and typescript 5.3.2 HOT 3
- "TypeError: require(...) is not a function" in ts-node dependecy
- extends of tsconfig.json doesn't work when it reference to other package HOT 2
- add --env-file environment variable similar to node v:20.6.0 HOT 9
- Support clearing the local context with .clear when starting programmatically
- In #!/bin/bash clear apt update apt upgrade apt install figlet -y figlet Basic Installation apt install toilet -y apt install cowsay -y apt install nano -y apt install ruby -y gem install lolcat figlet -f big Done !!! | lolcat echo echo -e "\e[1m Now Run \e[32mbash t-ban.sh\e[0m...!!!" echo echo -e "\e[1m\e[32m Developed by :\e[33m Sutariya Parixit (8h4i)" echo echo( there are Issu for In title The Over view and synonyms Not Seen in his real formet
- ts-node is unable to resolve tsconfig files in Yarn workspace HOT 2
- ESM: Cannot find module './index.js' and requiring "imaginaryUncacheableRequireResolveScript" HOT 1
- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" in Node v21.5.0 HOT 37
- "Cannot find package" when running mocha and importing between packages in monorepo HOT 1
- Can't use `--eval` with ESM
- calling `repl.start()` causes a doubling of stdin/stdout
- ts-node cannot run mixed ESM/CJS project HOT 2
- Cryptic error on invalid tsconfig.json, e.g. if attempting to extend nonexistent tsconfig file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-node.