复现问题
今天使用webStorm打开ant design pro项目,执行如下命令时:

npm install
1
却报出如下错误:

.git can't be found (see https://git.io/Jc3F9)
npm ERR! code 1
npm ERR! path D:\project\1myProject\superjson\superjsonweb\web
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c husky install

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\zxy\AppData\Local\npm-cache\_logs\2022-08-05T01_54_02_117Z-debug-0.log
1
2
3
4
5
6
7
8


根据其错误信息A complete log of this run can be found in:可知,完整的执行日志可以在如是文件中找到C:\Users\zxy\AppData\Local\npm-cache\_logs\2022-08-05T01_54_02_117Z-debug-0.log。

分析问题
分析错误日志文件
我们打开上述日志文件,找到报错的对应行信息,如下图所示:



分析index.js文件
在node_modules目录下的index.js文件中的第63行报出的错误信息,如下图所示:



然而,这里只是报错信息,并不能解决我们实际的问题,于是继续分析这张图片:



找到红色框上方的两行语句,如下所示:

> ant-design-pro@6.0.0-beta.1 prepare
> husky install
1
2
发现是安装husky出现了问题。

解决问题
我们打开package.json 文件,找到husky install指令,或者搜索prepare也可以定位到husky install指令,如下图所示:



使用如下命令,替换husky install:

 "prepare": "cd .. && husky install superjsonweb/.husky",
1
如下图所示:


重新执行指令npm install,便没有报出错误了,如下图所示:



但是,报出了如下提示:

231 packages are looking for funding
  run `npm fund` for details
1
2
那么,这是什么样的提示呢?可以参考博文:解决run npm fund for details的问题。
————————————————
版权声明:本文为CSDN博主「互联网全栈开发实战」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lvoelife/article/details/126172368
所有评论
加载评论 ...
发表评论