创建husky报错Error: can‘t create hook, .husky directory doesn‘t exist (try running husky install)

 报错信息:

admin@LAPTOP-VT2IJSLS MINGW64 /e/Club Management System
$ pnpm dlx husky-init && pnpm install
Packages: +2
++
Progress: resolved 2, reused 2, downloaded 0, added 2, done
husky-init updating package.json
  "husky install" command already exists in prepare script, skipping.
fatal: detected dubious ownership in repository at 'E:/Club Management System'
'E:/Club Management System' is owned by:
        'S-1-5-32-544'
but the current user is:
        'S-1-5-21-432826646-1384485975-3590503669-1001'
To add an exception for this directory, call:

        git config --global --add safe.directory 'E:/Club Management System'
husky - git command not found, skipping install
E:\.pnpm-store\v3\tmp\dlx-12420\node_modules\.pnpm\husky@8.0.3\node_modules\husky\lib\index.js:44
        throw new Error(`can't create hook, ${dir} directory doesn't exist (try running husky install)`);
        ^

Error: can't create hook, .husky directory doesn't exist (try running husky install)
    at set (E:\.pnpm-store\v3\tmp\dlx-12420\node_modules\.pnpm\husky@8.0.3\node_modules\husky\lib\index.js:44:15)
    at Object.<anonymous> (E:\.pnpm-store\v3\tmp\dlx-12420\node_modules\.pnpm\husky-init@8.0.0\node_modules\husky-init\lib\bin.js:17:17)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)      
    at node:internal/main/run_main_module:23:47

Node.js v18.16.0

解决办法:

git config --global --add safe.directory '项目路径'

如:

git config --global --add safe.directory 'E:/Club Management System'

  • 6
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值