How to make scripts in a t3-stack app (with tsx and t3-env)?
I am trying to create a scripts folder to run things along my website and create tools, test things and all.
I tried tsx with success, until I needed the env to be available (thus involving t3-env).
I am currently trying to do a small script to test inserting things in my database:
Until now, I did scripts that did not involve resources from the app but right now I would like to connect to my database but I get this error:
Solution:Jump to solution
For anyone looking for a solution... I managed to get it working after multiple try with the following setup:
1 - you will need the
dotenv
package
2 - my package.json
look like this:
```json...1 Reply
Solution
For anyone looking for a solution... I managed to get it working after multiple try with the following setup:
1 - you will need the
dotenv
package
2 - my package.json
look like this:
WIth this, I am able to run scripts with the following command:
pnpm run tsx scripts/any-script.ts