Gulp项目问题 | GitHub插件下载失败Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c “autoreconf -ivf“

在Windows环境下使用npm安装特定包时,由于GitHub资源库的DNS问题导致安装失败。错误提示包括getaddrinfo ENOENT等。解决方法是在本地hosts文件中添加GitHub相关域名的IP地址,清除npm缓存后再尝试安装。如果问题依然存在,可考虑更新hosts文件或刷新本地DNS。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 问题
    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
  2. 原因
    由于安装这些包时需要安装依赖包,而其中部分依赖包需要从GitHub上下载,而GitHub的资源库DNS有问题,导致这些依赖包无法安装而报错。
     
  3. 解决
    在本地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文件后刷新本地DNS

    ipconfig /flushdns
  4. npm清除所有缓存

    npm cache clean -f
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值