I have a React project, and it includes talking to an API.
I have a module defined in the project that abstracts away the api access.
So for example it has methods like addFoo
and getFoos
. I would like to use this module from a script that I would like to run directly on the command line. The purpose of the script is to load a bunch of data into a database via the api.
When I use plain .js
, it seems to be fairly easy to just run > node path/to/file
. The relative import paths work fine.
Issue
When I use .ts
it doesn't work. It complains that it can't find the module.
Question
What's the right way to run a .ts
CLI script in a React project directly? Or is this the wrong way to do this?
Thanks !