jquery - 不能 promise 。预提交 Hook 失败。获取: sh: 1: grunt: not found

标签 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)

描述:

我使用 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"
  }
}

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

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

最佳答案

好吧,它告诉你应该做什么:确保你安装了最新版本的node.js和npm。如果你这样做,告诉作者这在您的系统上失败:[...]

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

关于jquery - 不能 promise 。预提交 Hook 失败。获取: sh: 1: grunt: not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45052284/

相关文章:

node.js - npm global 没有被使用?

javascript - 使用 vega react 组件

jquery - 如果至少一个值不为空则发出警告

javascript - javascript代码什么时候执行?

git - git分支之间某个文件夹的差异

git - .gitignore 中的 !*/是什么意思

git - 如何从目录中删除新文件?

typescript - 如何在 TypeScript 1.8 中导入 jQuery npm 模块

jQuery - 悬停时的粗略淡入过渡

jquery - 使用 jQuery 添加多个背景