Get the
$PATHfrom 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).
npm install shell-pathWhen executed from a GUI app on macOS:
import{shellPath}from'shell-path';console.log(process.env.PATH);//=> '/usr/bin'console.log(awaitshellPath());//=> '/usr/local/bin:/usr/bin:...'console.log(awaitshellPath({shell: '/bin/bash'}));//=> '/usr/local/bin:/usr/bin:...'Returns a promise for the $PATH.
Returns the $PATH.
Type: object
Type: string
Default: User's default shell
The shell to read environment path from.
- fix-path - Fix the
$PATHon macOS when run from a GUI app - shell-env - Get environment variables from the shell
- shell-history - Get the command history of the user's shell