dw1284 / electron-node-config Goto Github PK
View Code? Open in Web Editor NEWConfiguration control for electron based node applications
License: MIT License
Configuration control for electron based node applications
License: MIT License
So I replaced my node-config with electron-node-config. If I run the express server normally, everything runs as expected. Now when I launch it via electron using the cli and not packaged. It throws errors. Makes developing hard if I have to build the app every time, rather than quick dev loading it.
First, thanks for forking node-config and fixing the issue on Electron.
Just discovered a limitation with this tool, unable to set NODE_ENV when building thru electron-builder
$ NODE_ENV=staging build ....
This happened because we are not allowed to pass env variables on a packed electron app on start.
What I had to do to make it work is this:
Add environment
field in package.json
Wrap electron-node-config
in some JS file
const pkg = require("../package");
process.env.NODE_ENV = pkg.environment;
module.exports = require('electron-node-config');
Load the wrapper instead of directly using electron-node-config
It both works when we execute our app via CLI ($ electron .
) or when we build different packed apps.
I did not yet submit a PR about our workaround because I think it may not be good practice to put environment
in package.json
. Let me know your thoughts.
Cheers!
C:\Users\elided\AppData\Roaming\npm\electron.cmd --nolazy --debug-brk=15312 main.js
WARNING: NODE_ENV value of 'dev' did not match any deployment config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
WARNING: No configurations found in configuration directory:C:\Users\elided\AppData\Roaming\npm\node_modules\electron\dist\resources\default_app.asar/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
Why is it lunging down a path in C:/Users instead of just using the /config folder beneath the working folder when I debug?
(I'm also pursuing this as an issue in the way Electron and VS Code are set up. Seriously, 35 years of software development experience, and I've gone back to noob status because of Electron.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.