create-react-app安装出错问题解决方法

2019-11-15,,

create-react-app慢的解决方法

在操作官方实例Create React App时,需要执行指令:

create-react-app my-app

来创建一个新的React应用。由于某原因,在拉取各种资源时,往往会巨慢,一直卡在

fetchMetadata: sill mapToRegistry uri http://registry.npmjs.org/whatwg-fetch

解决方案是换源,虽然平常使用cnpm来代替npm,但也只是使用新的指令而已,而在寻求create-react-app的相关配置希望修改registry时失败了,最后发现create-react-app指令默认调用npm,于是直接把npm的register给永久设置过来就好了,这样使用cnpm或者npm就没差别了。

在用create-react-app的时候。

报错

错误直接上图:

 

在SF上查到说是或许是因为国内npm拉去资源,拉去不到的问题,可以试着从解决创建create-react-app慢的方法着手:

解决方法:

//换源
npm config set registry https://registry.npm.taobao.org
//配置后通过以下方法验证是否成功
npm config get registry

 

设置成功后,再次执行create-react-app,当然成功啦。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持北冥有鱼。

您可能感兴趣的文章:

  • create-react-app 修改为多入口编译的方法
  • 在create-react-app中使用css modules的示例代码
  • 详解使用create-react-app添加css modules、sasss和antd
  • 详解create-react-app 自定义 eslint 配置
  • create-react-app修改为多页面支持的方法
  • 详解使用create-react-app快速构建React开发环境
  • 详解开发react应用最好用的脚手架 create-react-app
  • create-react-app构建项目慢的解决方法
  • react以create-react-app为基础创建项目

《create-react-app安装出错问题解决方法.doc》

下载本文的Word格式文档,以方便收藏与打印。