Answer the question
In order to leave comments, you need to log in
How to add a property to process.env?
Created a .env.local file in the root folder of the project, to which I added API_KEY. I want to refer to it in the component, downloaded via npm dotenv, added the line . I output to the console , but for some reason the value of this property is undefined require('dotenv').config()
console.log(process.env.API_KEY)
Answer the question
In order to leave comments, you need to log in
By default, in my opinion, the .env file is searched, but in the options you can specify the path if you have an arbitrary name, or the file lies in some place where the module cannot find it, let's say path: path.resolve(__dirname, '. env.local')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question