create-react-app创建Typescript+React项目报错

使用create-react-app新建一个使用ts的React项目,安装时遇到一些报错。通过以下命令得以解决
npm cache verify:验证缓存数据的有效性和完整性,清理垃圾数据。
npm install --registry=https://registry.npm.taobao.org:如果安装缓慢,可设置淘宝镜像
npx create-react-app my-app --template typescript:新建一个使用ts的React项目

具体尝试过程:

  1. 执行命令npx create-react-app my-app --typescript,报错
    (提示--typescript被弃用,使用--template typescript)

    Unexpected end of JSON input

  2. 网上查找需要输入命令npm clean cache --froce

    npm clean cache --froce

    (图中提示说,使用npm cache verify代替)

npm clean cache --froce之后也会有新的报错

code EINTEGRITY

  1. 执行npm cache verify
    npm cache verify

继续执行,无报错。但是最后安装template dependencies缓慢。


installing template dependencies缓慢
  1. 安装淘宝镜像npm install --registry=https://registry.npm.taobao.org
  2. 最后再执行npx create-react-app my-app --template typescript,安装成功。

你可能感兴趣的:(create-react-app创建Typescript+React项目报错)