Commitlint 不起作用。git commit -m commitlint 消息显示未知参数,husky 存在,代码为 1(错误)

AWE*_*UMI 2 husky git-husky commitlint

git commit -m "feat: 测试 commitlint 库" @commitlint/cli@16.2.3 - 检查你的提交消息

[input] 如果省略 --edit、--env、--from 和 --to 则从 stdin 读取

Options:
  -c, --color          toggle colored output           [boolean] [default: true]
  -g, --config         path to the config file                          [string]
      --print-config   print resolved config          [boolean] [default: false]
  -d, --cwd            directory to execute in
                                         [string] [default: (Working Directory)]
  -e, --edit           read last commit message from the specified file or      
                       fallbacks to ./.git/COMMIT_EDITMSG               [string]
  -E, --env            check message in the file at path given by environment   
                       variable value                                   [string]
  -x, --extends        array of shareable configurations to extend       [array]
  -H, --help-url       help url in error message                        [string]
  -f, --from           lower end of the commit range to lint; applies if        
                       edit=false                                       [string]
  -o, --format         output format of the results                     [string]
  -p, --parser-preset  configuration preset to use for
                       conventional-commits-parser                      [string]
  -q, --quiet          toggle console output          [boolean] [default: false]
  -t, --to             upper end of the commit range to lint; applies if
                       edit=false                                       [string]
  -V, --verbose        enable verbose output for reports without problems
                                                                       [boolean]
  -v, --version        display version information                     [boolean]
  -h, --help           Show help                                       [boolean]

Unknown argument: edit
husky - commit-msg hook exited with code 1 (error)

Run Code Online (Sandbox Code Playgroud)

AWE*_*UMI 11

对于Windows 操作系统,我稍后通过转到 .husky 文件夹并编辑npx --no -- commitlint editnpm commitlint --edit 来解决问题

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint edit 
Run Code Online (Sandbox Code Playgroud)

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit 

Run Code Online (Sandbox Code Playgroud)