DEV Community

Bruno Moura
Bruno Moura

Posted on

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)