javascriptnode.jselectronenv-cmd

After Electron package .env file variable are not setting up


In my Electron Project I have my env files like this

env files

and I have my package.json file like this

package-json

Issue is in the development when i use npm start .env variable setting up , but when I use npm package:win to package the project the .env variable are not setting up , How to fix this ?

After Package these are not setting up ,

env file content


Solution

  • dotenv not working correctly during packaging in an Electron app. Can go for these three options

    1. Use Electron Forge with Webpack
    2. Use a Configuration Service
    3. Use a JSON File and Create an Environment Handler