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"
}
}
出现这样的原因在于楼主使用了
husky
,并且配置了"precommit": "npm run lint"
因此会在你git commit的时候执行
npm run lint
也就是eslint --ext .js src test
如果报错的话,会返回非0,从而组织代码commit。
因此有两种方式解决: