Search code examples
environment-variablescreate-react-appmicrosoft-teamsteams-toolkit

Teams App not picking up env variables from .env.teamsfx.local while running locally, process.env is an empty object


Teams App not picking up env variables from .env.teamsfx.local (files generated automatically by toolkit) while running locally, process.env is an empty object. Below are the scripts from package.json:

"start": "env-cmd --silent -f .env.teamsfx.local react-scripts start",
"build": "env-cmd --silent -f .env.teamsfx.local react-scripts build",

This works when I create a new .env file but does not pickup env variables from .env.teamsfx.local file.

Note: package.json and env files are in the same directory i.e root directory


Solution

  • How did you start your react app? Just run npm run start and I believe the env variables from .env.teamsfx.local will be injected into the process.