Questions tagged [ts-node]
Short for TypeScript Node. Built to execute TypeScript for Node.js. You might also include TypeScript and/or Node.js - tags if you use this tag.
ts-node
511
questions
0
votes
0
answers
28
views
ts-node-dev doesn't support ts requires in js
I'm trying to import ts. files inside a .js file (reason is that I don't have time to fully migrate my project to typescript)
I figured out a way like that :
I have my routes.ts that I want to import ...
1
vote
1
answer
60
views
ts-node shadows import path with JSON files, but TypeScript does not raise issue at compile time
When the "resolveJsonModule" compiler option is specified, TypeScript appears to have very unusual behaviour if a JSON file has the same name as a TypeScript file:
myModule.json
{
"...
0
votes
0
answers
48
views
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for S:\projects\sofie\rethink-backend\src\main\typescript\utils\CalculateAge.ts
I was trying to run this file using the command ts-node, then I got this error. I'd installed ts-node via npm, so I don't know why the error still occured.
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: ...
0
votes
0
answers
37
views
Cannot find package
Libraries and communications:
typescript v5.4.5
node v20.11.1
pnpm v9.1.0
ts-node v10.9.2
nodemon v3.1.3
On Stack Overflow, I found a similar problem and solved it, but there is another problem ...
0
votes
0
answers
31
views
Node.JS console.log output is not shown in Windows cmd
I'd like to add some console.log debugging code into my TS script and it is not displayed currently.
I've added the following to package.json:
"start": "dotenv -- node --import tsx -e '...
0
votes
0
answers
54
views
ERR_REQUIRE_ESM: Require of ES Module in CommonJS Context (ts-node, svgdom)
I'm encountering the error "ERR_REQUIRE_ESM: require() of ES Module ..." whenever I install a new package or update an @types version. The specific module causing the issue seems to be Error ...
0
votes
1
answer
196
views
"'ts-node' is not recognized as an internal or external command, operable program or batch file" error even with npx
'ts-node' is not recognized as an internal or external command, operable program or batch file is about common problem: the installing of the npm package to the project does not mean the ...
0
votes
0
answers
19
views
ts-node ignore file global.d.ts or tsconfig.json?
I have a nodeJs project with typescript and then a tests for it;
i use mocha do this tests
.mocharc.json
{
"extension": [
"ts"
],
"spec": "tests/*.spec.ts&...
1
vote
1
answer
81
views
Can code files with a .cts extension in Node.js use ESM module syntax for imports and exports?
I created a new Node.js project with Node version 18.15.0. In the package.json file, I added the field "type": "module":
{
"name": "ts-node-test",
"...
0
votes
1
answer
30
views
ts-node imports .js modules over .ts modules of the same name
Say I have an esm sayhi.ts module:
const sayhi = () => 'hi in typescript';
export default sayhi;
And then I have the same module but it's a commonjs sayhi.js file:
const sayhi = () => 'hi in ...
4
votes
0
answers
2k
views
tsx vs ts-node comparison for executing typescript
I was looking for a complete impartial comparison between tsx and ts-node, but I couldn't find anything. What is the general difference between them, and do any of them come with caveats? It's a very ...
0
votes
0
answers
49
views
unable to run my Node.js typescript project on Windows with TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
My code works fine when I run in UNIX system. but when I tried to run on Windows system it is failing with following error
[nodemon] starting `ts-node index.ts --no-warnings`
TypeError [...
1
vote
1
answer
407
views
Fastest way to run typescript files
Background
From this repo I'm running a typescript program
node --loader ts-node/esm ./examples/ts/cli.ts bitget fetchBalance
The typescript version of the program a lot longer than the comparable js ...
0
votes
1
answer
352
views
Cannot find module 'src/instrumentation.ts' when using --require with ts-node
Using this as my starting point: https://opentelemetry.io/docs/languages/js/instrumentation/
I'm trying to pre-load opentelemetry instrumentation into my Express app using --require.
I added this to ...
0
votes
1
answer
120
views
"Cannot find name 'it'" but Mocha types are installed and added to compilerOptions
I'm getting this error trying to run Mocha tests in a node.js + typescript app:
Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `...