Skip to content

Instantly share code, notes, and snippets.

@julienetie
Last active March 24, 2024 04:25
Show Gist options
  • Save julienetie/8be97981a6ef8235be9ecc5f2495cf6e to your computer and use it in GitHub Desktop.
Save julienetie/8be97981a6ef8235be9ecc5f2495cf6e to your computer and use it in GitHub Desktop.
husky-pnpm-pre-commit-error-on-linux
@julienetie
Copy link
Author

(Tested on a Debian based distro)

When committing, you may get an error such as:

/home/<user>/.nvm/versions/node/v20.11.0/bin/pnpx: 1: Syntax error: word unexpected (expecting ")")
husky - pre-commit hook exited with code 2 (error)
  1. Make sure the pre-commit is executable
chmod +x .husky/pre-commit
  1. Change pnpx to pnpm
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm nx affected --target=ts-check
pnpm lint-staged --relative 

The pre-commit hook should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment