0

Azure Static Web App (SWA) with integrated API whose index.js has

require('dotenv').config({ path: './environment/misc.env'});

Local-run Azure Static Web Apps emulator perfect. Merged into GitHub master branch triggers Azure CI/CD deploy into Azure, test got

Stack: Error: Cannot find module 'dotenv'

dotenv is in SWA's root package.json

"dependencies":
{
  ...
  "dotenv": "^16.0.0"
}

GitHub project, Actions all jobs are good

Jeb50
  • 6,272
  • 6
  • 49
  • 87
  • 1
    Are these helpful ? https://stackoverflow.com/questions/67307614/azure-static-web-app-nodejs-env-variables, https://stackoverflow.com/questions/61407393/while-running-the-script-throws-cannot-find-module-dotenv, https://stackoverflow.com/questions/65749078/azure-static-web-app-environment-variable – Madhuraj Vadde Mar 16 '22 at 05:55

1 Answers1

0

SWA environment settings Front-end

  • Local, \src\app\environments\environment.ts (or your own customized location)
  • PROD AZ cloud, .yml file, add env

Backend

  • Local, api/local.settings.json
  • PROD AZ, Portal, Configuration
Jeb50
  • 6,272
  • 6
  • 49
  • 87