# electron-is-dev

> Check if Electron is running in development

Latest version **3.0.1** (published 2024-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install electron-is-dev
pnpm add electron-is-dev
yarn add electron-is-dev
bun add electron-is-dev
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2024-01-13 |
| First published | 2016-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 442 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | electron, dev, development, mode, prod, production, detect, check, debug, app |

## Links

- npm: https://www.npmjs.com/package/electron-is-dev
- Repository: https://github.com/sindresorhus/electron-is-dev
- Homepage: https://github.com/sindresorhus/electron-is-dev#readme
- Issues: https://github.com/sindresorhus/electron-is-dev/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/electron-is-dev

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 3.0.1 (latest) — 2024-01-13
- 3.0.0 — 2024-01-13
- 2.0.0 — 2021-02-28
- 1.2.0 — 2020-04-05
- 1.1.0 — 2019-04-11
- 1.0.1 — 2018-09-19
- 1.0.0 — 2018-09-19
- 0.3.0 — 2017-07-23
- 0.2.0 — 2017-06-30
- 0.1.2 — 2016-08-17
- 0.1.1 — 2016-05-13
- 0.1.0 — 2016-04-08

## README

# electron-is-dev

> Check if [Electron](https://electronjs.org) is running in development

Useful for enabling debug features only during development.

This package must be used from the Electron main process.

## Install

```sh
npm install electron-is-dev
```

*Requires Electron 28 or later.*

## Usage

```js
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`](https://www.electronjs.org/docs/api/app#appispackaged-readonly)?

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`](https://www.electronjs.org/docs/latest/api/context-bridge) in the [preload script](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload) to manually expose the variable:

```js
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:

```js
console.log(globalThis.isDev);
```

## Related

- [electron-util](https://github.com/sindresorhus/electron-util) - Useful utilities for developing Electron apps
- [electron-debug](https://github.com/sindresorhus/electron-debug) - Adds useful debug features to your Electron app

---
_Source: https://npm.io/package/electron-is-dev · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
