无法提交。预提交挂钩失败。获取:sh:1:grunt:not found

时间:2017-07-12 08:25:15

标签: jquery git npm webpack pre-commit-hook

问题:

每当我尝试提交更改时,我都会收到以前看不到的错误。

错误:

> jquery@3.2.1 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! jquery@3.2.1 precommit: `grunt lint:newer`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the jquery@3.2.1 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:

我使用webpack捆绑项目,npm用于包管理。 这是我的package.json文件:

{
  "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"
  }
}

项目构建没有任何错误。但是在提交尝试之后我得到了之前描述的错误。 不幸的是,这可能是由于我在npm install目录中使用node_modules/jquery而导致使用此package

我尝试删除项目中的node_modules并通过npm install重新安装,但错误没有改变。我应该做什么?

1 个答案:

答案 0 :(得分:0)

嗯,它告诉你你应该做什么:Make sure you have the latest version of node.js and npm installed.如果你这样做,Tell the author that this fails on your system:[...]

您无法提交,因为现有的预提交挂钩失败。预提交挂钩是每次尝试提交时执行的脚本。如果未成功退出,则中止提交。该脚本似乎尝试执行grunt,但找不到它。您应确保已安装并可用。