If you want to run "ts-node" in production with ESM, then use: "tsc --noEmit && node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only src/main.ts" (see github.com/TypeStrong/ts-node/issues/104#issuecomment-1941702624)
@humaitrix9 ай бұрын
Thank you Benny! Amazing video, not only sharing the solution but explaining why it's the best solution available at the moment! Tks a lot
@TypeScriptTV9 ай бұрын
Thank you, Daniel! It's important for me to not only show the "how" but also explain the "why". I try to follow this principle in all my TypeScript tutorials. 😀
@k3rnel_err0r10 ай бұрын
This is easily the most underrated TS channel on KZbin. Thank you for your videos Benny.
@TypeScriptTV10 ай бұрын
Thank you! I also think the same. 😅 Btw. I made an app for programmers: apps.apple.com/app/id659282498
@tonyg_nerd2 ай бұрын
😮 Mouth fell open watching this. There's no way that today's copy/paste developers are going to create quality software with scenarios like this. I've been doing this for decades, have been following advice for all of these various tools, to solve these problems, and had no clue about the details that you provided here. OMG - Thank you! I need to change my approach to this tooling ... maybe go back to BASIC. 😂
@HemantKumar-yk2jk2 ай бұрын
Excellent videos .. one of the best videos in TS
@TypeScriptTV2 ай бұрын
Thank you! It's also reported that using "vite-node src/main.ts" is a viable option.
@MonsterSmart3 ай бұрын
Great video. That was the last thing I couldn't figure out in my ts node setup
@leonardogonzalezrodriguez22909 ай бұрын
Thank you so much for your explanation, it helped me a lot
@mahdiahmadi504Ай бұрын
Thanks for your comprehensive video! I was struggling with those errors for 5 hours before finding a solution. I tried tsx and noticed that while it’s fast, it lacks type checking. Finally, I ended up using the command: nodemon --exec node --loader ts-node/esm src/index.ts This setup does perform type checking. For example, if you write let x: string = 20, nodemon crashes the app with an error. However, I noticed that, like node with ts-node/esm, it doesn’t provide a stack trace for errors. Do you have any suggestion?
@TypeScriptTVАй бұрын
Hi @mahdiahmadi504, to get stack traces, you can use tsimp (14:58) or run tsc --noEmit before executing ts-node-esm, as shown here: typescript.tv/hands-on/write-a-simple-typescript-script-with-esm/#fixing-err_unknown_file_extension
@evlbon3 ай бұрын
Its so stupid that ts-node --esm is not working with node v20+
@HemantKumar-yk2jk2 ай бұрын
can we run this main.ts directly in the aws lambda or do we need to convert to js ?? i am not sure how can we use this for aws lambda ??
@TypeScriptTV2 ай бұрын
To use your TypeScript code with AWS Lambda, you need to convert it to JavaScript: docs.aws.amazon.com/lambda/latest/dg/lambda-typescript.html
@rama30188 күн бұрын
haha, i work with separated workspace and this save me hahaha
@TypeScriptTV4 күн бұрын
Glad to hear this is helpful to you! By including a .nvmrc file in your repository, you can also configure nvm to automatically switch Node.js versions when necessary.
@seeyou798910 ай бұрын
Thanks but what if i have to use nodemon
@TypeScriptTV10 ай бұрын
When using nodemon, you can create a "nodemon.json" file in your repository and use the commands in the "exec" section.
@evlbon3 ай бұрын
can be nodemon --exec node --loader ts-node/esm index.ts
@sayandedotcom10 ай бұрын
how to do it with nodemon "node --loader ts-node/esm && nodemon ./index.ts"
@TypeScriptTV5 ай бұрын
Will you get type checking when doing this?
@evlbon3 ай бұрын
I think u mean smt like this nodemon --exec node --loader ts-node/esm index.ts