Windows 10下Node.js soap安装失败,求同问题经验及解决办法
问题场景
在Windows 10系统中执行npm install soap命令安装soap包时,出现网络相关错误,无法完成安装。具体报错信息如下:
error code 1
error git dep preparation failed
error command C:\Program Files\nodejs\node.exe C:\Users\mhiqbal\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js install --force --cache=C:\Users\mhiqbal\AppData\Local\npm-cache --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
error npm WARN using --force Recommended protections disabled.
error npm ERR! code ENOTFOUND
error npm ERR! syscall getaddrinfo
error npm ERR! errno ENOTFOUND
error npm ERR! network request to https://registry.kase.se/yTdajDWYTVuNFFmbAjvaYeFZtOyPVJQc/typescript/-/typescript-2.9.2.tgz failed, reason: getaddrinfo ENOTFOUND registry.kase.se
error npm ERR! network This is a problem related to network connectivity.
error npm ERR! network In most cases you are behind a proxy or have bad network settings.
error npm ERR! network
error npm ERR! network If you are behind a proxy, please make sure that the
error npm ERR! network 'proxy' config is set properly. See: 'npm help config'
error
error npm ERR! A complete log of this run can be found in:
同时直接访问报错中的tgz链接也无法打开。
解决步骤
1. 重置npm镜像源
报错显示请求的是registry.kase.se这个无法访问的私有源,先将npm镜像重置为官方源:
npm config set registry https://registry.npmjs.org/
如果网络访问官方源较慢,也可以切换到国内镜像:
npm config set registry https://registry.npmmirror.com/
2. 清理npm缓存
清理可能存在异常的缓存文件:
npm cache clean --force
3. 重新安装soap包
完成上述操作后,重新执行安装命令:
npm install soap
4. 检查网络代理配置(若处于代理环境)
如果你的设备连接的是需要代理的网络,先检查当前代理配置:
npm config get proxy npm config get https-proxy
如果发现代理配置错误或无效,执行以下命令清空:
npm config delete proxy npm config delete https-proxy
之后根据实际网络情况配置正确的代理,或联系网络管理员确认权限。
内容的提问来源于stack exchange,提问作者Mohsan

