鍍金池/ 問答/Linux  HTML/ git commit 報錯

git commit 報錯

git commit 項目報錯

提示:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ lint: eslint --ext .js src test
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersAdministratorAppDataRoamingnpm-cache_logs2018-07-11T09_37_29_235Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ precommit: npm run lint
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ precommit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersAdministratorAppDataRoamingnpm-cache_logs2018-07-11T09_37_29_296Z-debug.log

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

這是什么原因,怎么解決?
各位老鐵幫忙看下,謝謝~_~

npm run lint 提示:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ lint: eslint --ext .js src test
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersAdministratorAppDataRoamingnpm-cache_logs2018-07-11T09_53_08_135Z-debug.log

package.json:

{
"private": true,
"scripts": {
"start": "set PORT=7101 && roadhog server",
"build": "roadhog build",
"lint": "eslint --ext .js src test",
"precommit": "npm run lint"
},
"dependencies": {

"antd": "^3.6.3",
"antd-mobile": "^2.1.4",
"classnames": "^2.2.5",
"crypto-js": "^3.1.9-1",
"dva": "^2.1.0",
"moment": "^2.21.0",
"prop-types": "^15.6.0",
"qs": "^6.5.1",
"rc-form": "^2.1.7",
"rc-queue-anim": "^1.5.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-images": "^0.5.17",
"react-sticky": "^6.0.1",
"react-zmage": "^0.2.1",
"web-storage-cache": "^1.0.3"},

"devDependencies": {
"antd-mobile-demo-data": "^0.2.0",
"babel-plugin-dva-hmr": "^0.4.1",
"babel-plugin-import": "^1.6.3",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"css-loader": "^0.28.9",
"eslint": "^4.14.0",
"eslint-config-umi": "^0.1.1",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-import": "^2.6.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.1.0",
"husky": "^0.12.0",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"redbox-react": "^1.4.3",
"roadhog": "^2.0.0",
"style-loader": "^0.19.1"
}
}

回答
編輯回答
命多硬

eslint 報錯吧

2017年1月25日 13:47
編輯回答
舊酒館

代碼不符合 eslint 規(guī)范

2017年11月7日 14:51
編輯回答
萌吟

出現(xiàn)這樣的原因在于樓主使用了husky,并且配置了"precommit": "npm run lint"

因此會在你git commit的時候執(zhí)行npm run lint 也就是eslint --ext .js src test
如果報錯的話,會返回非0,從而組織代碼commit。

因此有兩種方式解決:

  1. 執(zhí)行npm run lint, 根據(jù)提示修改錯誤,如果是其他人的報錯,請求別人協(xié)助(推薦)
  2. git commit -m '' -n 強制推送
2018年3月2日 20:29
編輯回答
雅痞

執(zhí)行一次 eslint --ext .js src test 或者 npm run lint

2017年8月26日 16:32