Hi, I’m creating this new topic to ask how can we import other files in the console. Coming from rails, rails imports all the files as it was loaded by the loader on initialization.
I have some success by putting my file in /lib, and it has to be a js file, no luck with ts, I assume because Node repl cannot understand ts file. And then, using dynamic import.
Example: let {default: { default: WhatsAppBusinessAPI }} = await import('./api/src/lib/api_clients/whatsapp.js')
1 Like
Anyone know what is this line doing? It seems like it should transpile all files in /api/src/
directory and set the alias for /api/src
to src
, but it does not make all files including ts files under the /api/src/ directory available in the console… hmmm…
Latest update, require works on ts files!!!
To import ts file into the console, you just do const {default: WhatsAppBusinessAPI} = require('api/src/lib/api_clients/whatsapp')
. This whatsapp file is a whatsapp.ts
file.