DEV Community

Bruno Moura
Bruno Moura

Posted on

1

dotenv and typescript

When we are developing our app, it is very important to put things in its right place.

Here, I'm talking about "typescript" with "dotenv".

They are two powerful tool that increases considerably the development speed.

In order we can do that, we can do something like this,

.env file must exists in root application path.

package.json

"scripts": {
...
    "dev": "ts-node-dev --transpile-only -r dotenv/config -- src/main/server.ts",
...
  },
Enter fullscreen mode Exit fullscreen mode

That way, we don´t "dirty" our code when we have to load local env variables for our app.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more