Reputation: 358
I'm learning React and React-Redux and I'm trying to edit an existing project I found.
Inside the reducers
folder there is a file that has this line of code:
const { data } = await client(`${process.env.REACT_APP_BE}/videos`);
But there was no declaration of process.env
. Where can I find that file?
Upvotes: 6
Views: 19983
Reputation: 7787
To add on to Christian's answer, the process
is a Node global object that holds info and utilities related to the current running process, also including argv
(the argument list), uptime
, etc. process.env
lists all current environment variables (you can see this by running node
and then running process.env
in the Node REPL). Those environment variables are from your system, your shell config, and in the context of Node project, also loaded in from sources like a .env
file (usually using a library like dotenv
) and a docker-compose file. On macOS and Linux, you can see all the current environment variables for your shell session by running env
(on Windows it would be SET
).
Upvotes: 2
Reputation: 21384
That's not a file, it's an environment variable. It is defined in the context of where your application is running, presumably a start script.
Here is an example app and start command to illustrate:
main.js:
console.log(process.env.MY_VAR);
started using:
> MY_VAR="hello world" node main.js
hello world
Added: As others pointed out, if you created your apps using create-react-app then this article describes how to use .env
files in your project root folder to set such environment variables. For that it appears to be using this package, which you might find useful also in other contexts.
Otherwise I would look at the way you start your app (script/command) and follow the execution path until you find where that environment variable is set.
Upvotes: 4