由于节点应用程序中的 Husky 故障而无法提交
我创建了一个节点应用程序并安装了 Husky7.0.4 和 lint-staged12.3.5
以下是配置 .husky/pre-commit --- 文件
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run pre-commit
和以下是 package.json 配置
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --exec babel-node index.js",
"build": "rimraf dist/ && babel ./ --out-dir dist/ --ignore ./node_modules,./.babelrc,./package.json,./npm-debug.log --copy-files",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"lint:check": "eslint .",
"lint:fix": "eslint --fix .",
"pre-commit": "lint-staged",
"prepare": "husky install"
},
"lint-staged": {
"*.js": [
"lint:check",
"lint:fix",
"prettier:fix"
]
},
"dependencies": {
"lint-staged": "^12.3.5",
},
"devDependencies": {
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.5",
"@babel/node": "^7.16.8",
"@babel/preset-env": "^7.16.11",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.5.0",
"husky": "^7.0.4",
"nodemon": "^2.0.15",
"prettier": "^2.5.1"
}
但是每次提交代码时我都会收到以下错误
> [email protected] pre-commit
> lint-staged
✔ Preparing lint-staged...
⚠ Running tasks for staged files...
❯ package.json — 1 file
❯ *.js — 1 file
✖ lint:check [ENOENT]
◼ lint:fix
◼ prettier:fix
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...
✖ lint:check failed without output (ENOENT).
husky - pre-commit hook exited with code 1 (error)
I have created a node application and installed Husky7.0.4 and lint-staged12.3.5
following are the configuration for
.husky/pre-commit --- file
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run pre-commit
and following are the package.json config
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --exec babel-node index.js",
"build": "rimraf dist/ && babel ./ --out-dir dist/ --ignore ./node_modules,./.babelrc,./package.json,./npm-debug.log --copy-files",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"lint:check": "eslint .",
"lint:fix": "eslint --fix .",
"pre-commit": "lint-staged",
"prepare": "husky install"
},
"lint-staged": {
"*.js": [
"lint:check",
"lint:fix",
"prettier:fix"
]
},
"dependencies": {
"lint-staged": "^12.3.5",
},
"devDependencies": {
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.5",
"@babel/node": "^7.16.8",
"@babel/preset-env": "^7.16.11",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.5.0",
"husky": "^7.0.4",
"nodemon": "^2.0.15",
"prettier": "^2.5.1"
}
But I am getting the following error every time I am committing my code
> [email protected] pre-commit
> lint-staged
✔ Preparing lint-staged...
⚠ Running tasks for staged files...
❯ package.json — 1 file
❯ *.js — 1 file
✖ lint:check [ENOENT]
◼ lint:fix
◼ prettier:fix
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...
✖ lint:check failed without output (ENOENT).
husky - pre-commit hook exited with code 1 (error)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以通过将 lint-stage 中的任务从 更改为 来解决此
问题
I am able to fix the issue by changing the tasks in lint-stage from
to
我可以通过更改来解决问题
I am able to fix the issue by changing