`npx mrm@2 lint-staged` 抛出 `.git` 无法找到 husky 自定义目录的错误
`npx mrm@2 lint-staged` throw err that `.git` can't be found husky custom directrory
xxx-MacBook-Pro:client xxx$ npx mrm@2 lint-staged
npx: installed 239 in 8.29s
Running lint-staged...
/Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/bin/mrm.js:56
throw err;
^
Error: .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory)
at Object.install (/Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/node_modules/husky/lib/index.js:20:15)
at task (/Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/node_modules/mrm-task-lint-staged/index.js:214:8)
at /Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/src/index.js:170:20
我在尝试使用 lint-staged
安装 Pre-commit Hook
时遇到错误
环境
- npm:6.14.17
- 节点:14.19.2
固定:
npx mrm@2 lint-staged
失败
修复 npm prepare 脚本
"prepare": "cd .. && husky install client/.husky"
运行 npm i
然后
已手动添加pre-commit
#!/bin/sh
"$(dirname "[=10=]")/_/husky.sh"
cd client && npx lint-staged
运行 npm i
再一次
原因:package.json file and .git directory are not at the same level.
我的代码结构:
client
server
.gitignore
xxx-MacBook-Pro:client xxx$ npx mrm@2 lint-staged
npx: installed 239 in 8.29s
Running lint-staged...
/Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/bin/mrm.js:56
throw err;
^
Error: .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory)
at Object.install (/Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/node_modules/husky/lib/index.js:20:15)
at task (/Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/node_modules/mrm-task-lint-staged/index.js:214:8)
at /Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/src/index.js:170:20
我在尝试使用 lint-staged
Pre-commit Hook
时遇到错误
环境
- npm:6.14.17
- 节点:14.19.2
固定:
npx mrm@2 lint-staged
失败
修复 npm prepare 脚本
"prepare": "cd .. && husky install client/.husky"
运行
npm i
然后已手动添加
pre-commit
#!/bin/sh "$(dirname "[=10=]")/_/husky.sh" cd client && npx lint-staged
运行
npm i
再一次
原因:package.json file and .git directory are not at the same level.
我的代码结构:
client
server
.gitignore