question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set env variable to the packed app ?

See original GitHub issue
  • Version: 19.22.1
  • Target: Windows (NSIS)

Hi, I try to make an app with electron-builder and I neet to set NODE_ENV=production. I use cross-env to set it, I try to put it on my scripts (start, pack and dist) but doesn’t work.

Any idea how can I do this ? Do I miss something ?

I made this temporally fix but if any way exist to add env variable to the packed app, it can be awesome !

if (process.env.NODE_ENV == undefined) process.env.NODE_ENV = "production"

Thank’s in advance !

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
daniellizikcommented, Dec 20, 2018

Is it suitable for you? If not, for what do you need such env for packed app?

Late reply but yes, in my app I’m simply doing mainWindow.loadURL(...) but these need to be pointed to different deploy targets…localhost, staging, pilot, etc., prod.

6reactions
daniellizikcommented, Feb 4, 2020

@alexandermckay that’d work if you only had two environments as the docs suggest. If you have like three or more you need something else.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I set NODE_ENV=production on Electron app when ...
You can always set that env variable in your application like this: process.env.NODE_ENV = 'production' . You could integrate that with electron ...
Read more >
Environment variables - Cloud Native Buildpacks
Environment variables are a common way to configure various buildpacks at build-time. Below are a few ways you can do so. All of...
Read more >
Environment Variables - Electron
Certain Electron behaviors are controlled by environment variables ... NODE_OPTIONS are explicitly disallowed in packaged apps, except for the following:.
Read more >
Environment Variables: What They Are and How To Use Them
Environment Type: Environment variables are often used to store the name of the environment in which the app is currently running. The app's...
Read more >
Use environment variables | Cloud Run Documentation
The environment variables defined in the container runtime contract are reserved and cannot be set. In particular, the PORT environment variable is injected ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found