nmp安装插件遇到的问题

通过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

总结:和配置没有关系,还是网络的原因,但是两个网络有什么差别不是很清楚。网络的知识不太懂。

安装Node.js和npm并进行环境配置,首先你需要下载Node.js的安装包并运行安装程序。运行安装程序后,按照安装向导的指示进行安装。在安装过程中,你可以选择添加Node.js的安装路径到环境变量中。 另一种方法是手动修改npm的配置文件。你可以在Node.js的安装目录中找到`node_modules\npm.npmrc`文件,打开它并修改以下内容: ``` prefix =C:\node\node_global cache = C:\node\node_cache ``` 将`prefix`设置为你想要的全局安装路径,将`cache`设置为你想要的缓存路径。保存修改后的文件。 在安装完成后,你可以在控制台中输入`node -v`和`npm -v`来验证Node.js和npm的版本。 如果你想使用淘宝镜像来加快npm的下载速度,你可以使用以下命令来安装淘宝cnpm: ``` npm install -g cnpm -registry=https://registry.npm.taobao.org ``` 安装完成后,你可以使用`cnpm -v`来验证cnpm的版本。注意,cnpm的命令与npm的命令相同。 如果你在运行nrm相关命令时遇到了错误,可能是因为没有配置环境变量。你可以按照以下步骤来解决这个问题: 1. 在控制台中运行`npm config ls`来查看Node.js的全局安装路径,其中的`prefix`就是全局安装路径。 2. 打开计算机的属性,点击高级系统设置,找到环境变量。 3. 在用户变量或系统变量的Path中,编辑并添加全局安装路径。 4. 重启控制台。 这样,你就完成了Node.js和npm安装和环境配置。现在你可以使用Node.js和npm来开发和管理你的项目了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Nodejs超详细安装及环境配置](https://blog.csdn.net/weixin_43937315/article/details/106901979)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [NodeJS、NPM安装及配置](https://blog.csdn.net/weixin_44722346/article/details/102546402)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值