NPM
NPM package
npm install --save-dev lefthook
yarn add --dev lefthook
pnpm add -D lefthook
Note
If you use pnpm package manager make sure to update pnpm-workspace.yamls onlyBuiltDependencies with lefthook and add lefthook to pnpm.onlyBuiltDependencies in your root package.json, otherwise the postinstall script of the lefthook package won’t be executed and hooks won’t be installed.
Choose right package
Lefthook supports three NPM packages with different ways to deliver the executables
lefthook installs one executable for your system
npm install --save-dev lefthooklegacy[1] @evilmartians/lefthook installs executables for all OS
npm install --save-dev @evilmartians/lefthooklegacy[1:1] @evilmartians/lefthook-installer fetches the right executable on installation
npm install --save-dev @evilmartians/lefthook-installer