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

Godhwani, Naina 41 Reputation points
2022-08-23T06:01:57.58+00:00

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 pick-up env variables from .env.teamsfx.local file.

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

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,077 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,847 questions
{count} votes

Accepted answer
  1. Nivedipa-MSFT 2,806 Reputation points Microsoft Vendor
    2022-09-08T18:31:35.967+00:00

    You can follow the steps to solve your problem:

    1. Add a script "dev:teamsfx": "env-cmd --silent -f .env.teamsfx.local npm run start" in package.json.
    2. Update the "Start Frontend" task like this: https://github.com/OfficeDev/TeamsFx-Samples/blob/dev/hello-world-tab/.vscode/tasks.json#L35-L44

    Thanks,
    Nivedipa


    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.


0 additional answers

Sort by: Most helpful