首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由于节点应用程序中的Husky失败而无法提交

由于节点应用程序中的Husky失败而无法提交
EN

Stack Overflow用户
提问于 2022-03-09 15:57:11
回答 1查看 2.1K关注 0票数 2

我创建了一个节点应用程序,并安装了Husky7.0.4和lint-staged12.3.5

下面是..husky/预提交--文件的配置

代码语言:javascript
复制
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pre-commit

下面是package.json配置

代码语言:javascript
复制
"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"
  } 

但是,每次提交代码时,我都会得到以下错误

代码语言:javascript
复制
> node-app@1.0.0 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)  
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-07 16:56:45

我能够通过在衣片阶段改变任务来解决问题

代码语言:javascript
复制
"lint-staged": {  
  "*.js": [ 
      "lint:check", 
      "lint:fix", 
      "prettier:fix" 
  ] 
 } 

代码语言:javascript
复制
"lint-staged": { 
  "*.js": [ 
    "npm run lint:check", 
    "npm run lint:fix", 
    "npm run prettier:fix" 
   ] 
 }
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71412253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档