-1

I'm using husky in my React project for pre-commit. When using command to commit husky running normally. But when I'm using GitHub Desktop to commit it throws an error. How can I fix that?

This is the error message from GitHub Desktop:

/bin/bash: C:/Program Files/nodejs/npm: No such file or directory
husky - pre-commit hook exited with code 127 (error)
husky - command not found in PATH=/mingw64/libexec/git-core:/mingw64/bin:/usr/bin:/c/Users/phamm/bin:/mingw64/bin:/mingw64/usr/bin:/c/Program Files/Common Files/Oracle/Java/javapath:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/Program Files/Intel/WiFi/bin:/c/Program Files/Common Files/Intel/WirelessCommon:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/Git/cmd:/c/Program Files/Java/jdk-20/bin:/c/Program Files/nodejs:/c/Users/phamm/AppData/Local/Microsoft/WindowsApps:/c/Users/phamm/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/phamm/AppData/Roaming/npm:/c/Users/phamm/AppData/Local/GitHubDesktop/bin

This is my pre-commit file:

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run lint

And this is my package.json

{
  "name": "vite-project",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview",
    "prepare": "husky install"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@types/react": "^18.2.15",
    "@types/react-dom": "^18.2.7",
    "@vitejs/plugin-react": "^4.0.3",
    "eslint": "^8.46.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-import": "^2.28.0",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-prettier": "^5.0.0",
    "eslint-plugin-react": "^7.33.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.3",
    "husky": "^8.0.3",
    "prettier": "^3.0.1",
    "vite": "^4.4.5"
  }
}

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437

0 Answers0