How important is . env in React?

Asked

Viewed 1,485 times

0

I am developing a website in React and I came across the file . env and it contains the following script NODE_PATH=./src What would be your importance in React ? Because my server only worked when I include this file in the project directory. I need an answer that is clear on the subject, answers without grounds will be flagged.

1 answer

1


The file . env is the file where the environment variables of your application are.

Somewhere in your application it must be using the variable 'NODE_PATH' and so it didn’t work. In this file you can also add other important settings if you need to centralize them.

You can take these environment variables by: process.env.SUA_VARIAVEL

Let’s assume that you want to type in only 1 place the name of your application, so you don’t need to change in all the files you created. Dai in this case you could add in your . env the following:

MY_APP_TITLE=Name of my APP

and there in your js file you take this data with process.env.MY_APP_TITLE

  • In case it would just be a dependencies startup file?

  • No, dependencies are listed in package.json

  • 1

    I updated the answer description, see if it helps

  • Has some source so I can read the doc completely ?

  • I don’t have to, you have to search something on Dad google

Browser other questions tagged

You are not signed in. Login or sign up in order to post.