21 questions
0
votes
0
answers
26
views
JS/TS: What is the correct scope for functions defined in a loop? [duplicate]
Consider the following code:
console.log(process)
for (;;) {
function process() {}
}
This runs fine in node, printing the process variable. But using tsx it prints undefined instead. There's no TS ...
1
vote
0
answers
97
views
Why is a top-level code executed twice in NodeJs?
I am modifying a project where a file contains some infrastructure variables. I executed code with side effects at the top level, but found that the side effects were repeatedly triggered during ...
1
vote
0
answers
172
views
How to run .ts file inside a turbo repo?
I have a turbo-repo project.
My goal is to run "index.ts" file located in "./apps/backend/src/migrations/dbMigrations/index.ts". I've tried to run from "backend" folder ...
1
vote
1
answer
178
views
IntelliJ IDEA and ts-node does not detect the files covered by inherited tsconfig.json
First of all, looks like this problem is complex. Besides IntelliJ IDEA and ts-node, it could be the problems with TypeScript and tsx (looks like this topic is related). Currently I am not sure on ...
1
vote
1
answer
58
views
How to use multer to upload images with index?
I am creating a product with its variants. Variant is e.g a Shirt can has a variant of Blue color and XL size. So I need to upload its variants along with their images. If I send body like
variants : ...
0
votes
0
answers
76
views
Is it Possible to Include CSS Files in TSX Watch Mode
I am using the tsx package to monitor typescript files and live reload my express server when a change is made to any of its dependencies. I would like to also refresh the page when a CSS file is ...
0
votes
0
answers
81
views
While running npm install it stucks at idealTree: sill idealTree buildDeps
I had tried to updating node version and cross checked my network status and its working but unable to run npm install command since it gets stucked at sill idealTree buildDeps
Im using nextjs14 for ...
0
votes
1
answer
189
views
Multiple 'Restarting server/server.js' messages when using 'tsx --watch' in script
I've added a tsx --watch command to my package.json scripts to watch changes in my server file. Here's the relevant part of my package.json:
"scripts": {
"dev": "...
1
vote
1
answer
481
views
Node.js can't read .env
package.json:
"scripts": {
"dev": "node --env-file=.env && tsx watch src/server.ts",
The server.ts is the entry point of the app, and it works if I remove ...
1
vote
1
answer
905
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
416
views
global variable in typescript isnt working
I have a problem with the implementation of the signin function in my application. I have a global declaration for this function, but while using it I got an error saying 'Element implicitly has an '...
0
votes
1
answer
687
views
How do I define a named function within page.evaluate without a ReferenceError?
Edit: It turns out that the following is an issue caused by running the code with tsx, not an issue in playwright. To reproduce, run the code below with npx tsx <file-with-code>.ts.
You can get ...
3
votes
1
answer
2k
views
How to run mocha with the tsx TypeScript runner
I'm using the tsx command (similar to ts-node) to run all my TypeScript code.
How can I use tsx to run my Mocha test suite?
0
votes
2
answers
1k
views
Using --expose-gc for TypeScript with ts-node or tsx
Neither ts-node nor tsx seem to support the --expose-gc flag, so the garbage collector object global.gc is always undefined. How am I supposed to clean up memory in my TypeScript code?
2
votes
1
answer
395
views
Package tsx library into executable
I want to package the typescript-runner tsx into an executable so that it is not dependent on nodejs or npm to be ran. How is this possible? I wanted to use vercel/pkg but it seems to have problems ...
2
votes
1
answer
152
views
ts-node cannot find dependent module
Assume to have simple typescript program having two files:
src/hello.js
export default function hello() {
return 'Hello world'
}
src/say.js
import hello from './hello.js'
console.log(hello())
with ...
1
vote
1
answer
208
views
Running Typescript script with ts-node fails to import non src module from node library
I have a script that, given some input, uses the three.js library to apply geometric transformations to some input data. I run this script using ts-node pipeline.ts. My project is structured as ...
1
vote
1
answer
937
views
Use ts-node (or similar) to import both npm packages exported using ESM and CommonJS, using esm import
I would like a setup for my project with the following configurations.
I would like to use typescript in my source code.
I would like to use ESM only in my source code, ie. import foo from 'bar'.
I ...
0
votes
1
answer
1k
views
How do I use dotenv with the tsx REPL for typescript?
When I run npx tsx, I get a REPL that lets me require modules like so:
> const dotenv = require('dotenv');
> dotenv.config({ path: './config/env' }); // There's an index file in the env ...
4
votes
1
answer
1k
views
tsx could not find directory
I'm using Node 19 and have a small library using TypeScript and the builtin testrunner. Based on this Github issue comment I'm trying to test the .ts files.
tsconfig.json
{
"compilerOptions&...
1
vote
1
answer
5k
views
The term 'ts-node' is not recognized
I am following a tutorial and the guy uses ts-node, so I did the same and installed it through yarn but it showed this error
ts-node : The term 'ts-node' is not recognized as the name of a cmdlet, ...