# shell-path

> Get the $PATH from the shell

Latest version **3.1.0** (published 2025-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install shell-path
pnpm add shell-path
yarn add shell-path
bun add shell-path
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2025-08-21 |
| First published | 2015-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 80 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus, silverwind |
| Keywords | path, macos, env, environment, variable, shell, sh, zsh, electron |

## Links

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

## Dependencies (1)

- [shell-env](https://npm.io/package/shell-env.md) ^4.0.1

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 3.1.0 (latest) — 2025-08-21
- 3.0.0 — 2021-08-25
- 2.1.0 — 2016-11-09
- 2.0.0 — 2016-02-19
- 1.0.8 — 2016-01-23
- 1.0.7 — 2016-01-20
- 1.0.6 — 2016-01-18
- 1.0.5 — 2016-01-16
- 1.0.4 — 2015-11-03
- 1.0.3 — 2015-10-29
- 1.0.2 — 2015-07-10
- 1.0.1 — 2015-04-27
- 1.0.0 — 2015-04-27

## README

# shell-path

> Get the [`$PATH`](https://en.wikipedia.org/wiki/PATH_(variable)) from the shell

Useful for Electron apps as GUI apps on macOS do not inherit the `$PATH` defined in your dotfiles *(.bashrc/.bash_profile/.zshrc/etc)*.

## Install

```sh
npm install shell-path
```

## Usage

When executed from a GUI app on macOS:

```js
import {shellPath} from 'shell-path';

console.log(process.env.PATH);
//=> '/usr/bin'

console.log(await shellPath());
//=> '/usr/local/bin:/usr/bin:...'

console.log(await shellPath({shell: '/bin/bash'}));
//=> '/usr/local/bin:/usr/bin:...'
```

## API

### shellPath(options?)

Returns a promise for the `$PATH`.

### shellPathSync(options?)

Returns the `$PATH`.

#### options

Type: `object`

##### shell

Type: `string`\
Default: [User's default shell](https://github.com/sindresorhus/default-shell)

The shell to read environment path from.

## Related

- [fix-path](https://github.com/sindresorhus/fix-path) - Fix the `$PATH` on macOS when run from a GUI app
- [shell-env](https://github.com/sindresorhus/shell-env) - Get environment variables from the shell
- [shell-history](https://github.com/sindresorhus/shell-history) - Get the command history of the user's shell

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