Dasshield
Dasshield

Reputation: 167

Can't commit. Pre-commit hook failed. Getting: sh: 1: grunt: not found

Problem:

Every time I try to commit changes I'm getting previously unseen error.

Error:

> [email protected] precommit /home/usr1/-/-/-/node_modules/jquery
> grunt lint:newer

sh: 1: grunt: not found

npm ERR! Linux 4.8.0-56-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "precommit"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] precommit: `grunt lint:newer`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] precommit script 'grunt lint:newer'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jquery package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     grunt lint:newer
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs jquery
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls jquery
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/usr1/practice/web/IgorVit/node_modules/jquery/npm-debug.log

husky - pre-commit hook failed (add --no-verify to bypass)

Descripltion:

I'm using webpack to bundle project, npm for package management. Here is my package.json file:

{
  "name": "typescript-react-webpack",
  "scripts": {
    "build": "webpack"
  },
  "devDependencies": {
    "react-dom": "^15.6.1",
    "react-router-dom": "^4.1.1",
    "ts-loader": "^2.2.0",
    "typescript": "^2.3.4",
    "webpack": "^3.0.0"
  },
  "dependencies": {
    "@types/jquery": "^3.2.5",
    "@types/node": "^8.0.10",
    "@types/react-dom": "^15.5.1",
    "@types/react-redux": "^4.4.45",
    "@types/react-router": "^4.0.11",
    "@types/react-router-dom": "^4.0.4",
    "css-loader": "^0.28.4",
    "extract-text-webpack-plugin": "^2.1.2",
    "firebase": "^4.1.3",
    "firebaseui": "^2.2.1",
    "jquery": "^3.2.1",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-redux": "^5.0.5",
    "react-router": "^4.1.1",
    "redux": "^3.7.1",
    "style-loader": "^0.18.2"
  }
}

Project builds without any errors. But after an commit attempt I get previously described error. Unfortunately, it may be caused by my use of npm install in node_modules/jquery directory, that used this package.

I've tried to delete node_modules in my project and to reinstall them through npm install but error hadn't changed. What I'm supposed to do?

Upvotes: 2

Views: 6969

Answers (1)

kowsky
kowsky

Reputation: 14459

Well, it tells you what you're supposed to do: Make sure you have the latest version of node.js and npm installed. If you do, Tell the author that this fails on your system:[...]

You are unable to commit because the pre-commit hook that is in place fails. A pre-commit hook is a script that is executed every time you try to commit. If it does not exit successfully, the commit is aborted. The script seems to try to execute grunt, but cannot find it. You should make sure it's installed and available.

Upvotes: 1

Related Questions