How to run JS file from typescript code (Node js)

How to run JS file from typescript code (Node js)?
In this case, I need to throw the global scope there, which I assigned

example:

GlobalScope(Ts):

globalThis.names = ['Joe', 'Bob', 'John'];

JS Script(run in runtime):

console.log(names[1]);

131 thoughts on “How to run JS file from typescript code (Node js)”

Leave a Comment