通过npm安装antd时
PS D:\VscWorkspace\my-react-app> npm config get registry
http://registry.npm.taobao.org/
使用淘宝镜像安装
PS D:\VscWorkspace\my-react-app> npm install antd --save
npm WARN ts-pnp@1.0.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://cdn.npm.taobao.org/lodash.keys/-/lodash.keys-3.1.2.tgz failed, reason: getaddrinfo EAI_AGAIN cdn.npm.taobao.org cdn.npm.taobao.org:443
通过cnpmjs安装,出现如下错误:
PS D:\VscWorkspace\my-react-app> npm config set registry http://registry.cnpmjs.org
PS D:\VscWorkspace\my-react-app> npm config get registry
http://registry.cnpmjs.org/
PS D:\VscWorkspace\my-react-app> npm install antd --save
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to http://registry.cnpmjs.org/antd failed, reason: getaddrinfo ENOTFOUND registry.cnpmjs.org registry.cnpmjs.org:80
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
解决过程:查了网上的很多解决方案,都没有生效
比如
1、重新设置.npmrc中的配置,
2、设置registry npm config set registry https://registry.npm.taobao.org
3、设置代理
我的解决方案:
我之前用的是家里的无线网络,后来连接自己的手机热点安装就好了。
PS D:\VscWorkspace\my-react-app> npm install antd --save
npm WARN ts-pnp@1.0.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ antd@3.13.2
added 98 packages from 132 contributors and audited 38062 packages in 39.06s
found 0 vulnerabilities
总结:和配置没有关系,还是网络的原因,但是两个网络有什么差别不是很清楚。网络的知识不太懂。