Socket
Socket
Sign inDemoInstall

electron-is-dev

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    electron-is-dev

Check if Electron is running in development


Version published
Weekly downloads
110K
increased by8.99%
Maintainers
1
Install size
4.20 kB
Created
Weekly downloads
 

Readme

Source

electron-is-dev

Check if Electron is running in development

Useful for enabling debug features only during development.

This package must be used from the Electron main process.

Install

npm install electron-is-dev

Requires Electron 28 or later.

Usage

import isDev from 'electron-is-dev';

if (isDev) {
	console.log('Running in development');
} else {
	console.log('Running in production');
}

You can force development mode by setting the ELECTRON_IS_DEV environment variable to 1.

FAQ

How is this different than app.isPackaged?

This package existed long before that property. The benefit of this package is that you can override the value using an environment variable.

How do I use this in the renderer process?

You can use contextBridge in the preload script to manually expose the variable:

import {contextBridge} from 'electron';
import isDev from 'electron-is-dev';

contextBridge.exposeInMainWorld('isDev', isDev);

You can then access it in globalThis from the renderer process:

console.log(globalThis.isDev);
  • electron-util - Useful utilities for developing Electron apps
  • electron-debug - Adds useful debug features to your Electron app

Keywords

FAQs

Last updated on 13 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc