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

阅读 7.7k
4 个回答

出现这样的原因在于楼主使用了husky,并且配置了"precommit": "npm run lint"

因此会在你git commit的时候执行npm run lint 也就是eslint --ext .js src test
如果报错的话,会返回非0,从而组织代码commit。

因此有两种方式解决:

  1. 执行npm run lint, 根据提示修改错误,如果是其他人的报错,请求别人协助(推荐)
  2. git commit -m '' -n 强制推送

执行一次 eslint --ext .js src test 或者 npm run lint

代码不符合 eslint 规范

eslint 报错吧

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题