- 问题
E:\gulp Project\hello-gulp>npm install --save-dev gulp-jshint jshint > gifsicle@5.2.1 postinstall E:\gulp Project\hello-gulp\node_modules\gifsicle > node lib/install.js getaddrinfo ENOENT raw.githubusercontent.com gifsicle pre-build test failed compiling from source Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "autoreconf -ivf" 'autoreconf' �����ڲ����ⲿ���Ҳ���ǿ����еij��� ���������ļ��� at E:\gulp Project\hello-gulp\node_modules\bin-build\node_modules\execa\index.js:231:11 at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Promise.all (index 0) > mozjpeg@7.1.1 postinstall E:\gulp Project\hello-gulp\node_modules\mozjpeg > node lib/install.js getaddrinfo ENOENT raw.githubusercontent.com mozjpeg pre-build test failed compiling from source Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "autoreconf -fiv" 'autoreconf' �����ڲ����ⲿ���Ҳ���ǿ����еij��� ���������ļ��� at E:\gulp Project\hello-gulp\node_modules\bin-build\node_modules\execa\index.js:231:11 at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Promise.all (index 0) npm WARN hello-gulp@1.0.0 No description npm WARN hello-gulp@1.0.0 No repository field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: gifsicle@5.2.1 (node_modules\gifsicle): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: gifsicle@5.2.1 postinstall: `node lib/install.js` npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! mozjpeg@7.1.1 postinstall: `node lib/install.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the mozjpeg@7.1.1 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! H:\nodejs\node_modules\node_cache\_logs\2021-11-06T08_52_44_302Z-debug.log
- 原因
由于安装这些包时需要安装依赖包,而其中部分依赖包需要从GitHub上下载,而GitHub的资源库DNS有问题,导致这些依赖包无法安装而报错。
- 解决
在本地hosts文件中(路径C:\Windows\System32\drivers\etc)添加以下内容(Github相关域名的解析地址),然后用npm清楚所有缓存(清除命令为:>npm cache clean -f),之后再重新安装就成功了。192.30.255.112 gist.github.com 192.30.255.112 github.com 192.30.255.112 www.github.com 151.101.56.133 avatars0.githubusercontent.com 151.101.56.133 avatars1.githubusercontent.com 151.101.56.133 avatars2.githubusercontent.com 151.101.56.133 avatars3.githubusercontent.com 151.101.56.133 avatars4.githubusercontent.com 151.101.56.133 avatars5.githubusercontent.com 151.101.56.133 avatars6.githubusercontent.com 151.101.56.133 avatars7.githubusercontent.com 151.101.56.133 avatars8.githubusercontent.com 151.101.56.133 camo.githubusercontent.com 151.101.56.133 cloud.githubusercontent.com 151.101.56.133 gist.githubusercontent.com 151.101.56.133 marketplace-screenshots.githubusercontent.com 151.101.56.133 raw.githubusercontent.com 151.101.56.133 repository-images.githubusercontent.com 151.101.56.133 user-images.githubusercontent.com
如果修改后再次重装还是报错,可以在github.com搜索最新的hosts文件;
更改hosts文件后刷新本地DNSipconfig /flushdns
-
npm清除所有缓存
npm cache clean -f