react-native create-react-app创建项目报错SyntaxError: Unexpected end of JSON input while parsing near '......

 

SyntaxError: Unexpected end of JSON input while parsing near '...ttachment":false,"tar'

错误情况

执行 下面命令行时,报错

create-react-app my-react-app

npm错误日志如下

161 silly pacote version manifest for webpack@3.8.1 fetched in 116ms
162 silly resolveWithNewModule webpack@3.8.1 checking installable status 163 http fetch GET 304 https://registry.npm.taobao.org/sw-precache-webpack-plugin 155ms (from cache) 164 silly pacote version manifest for sw-precache-webpack-plugin@0.11.4 fetched in 156ms 165 silly resolveWithNewModule sw-precache-webpack-plugin@0.11.4 checking installable status 166 http fetch GET 304 https://registry.npm.taobao.org/eslint-plugin-react 406ms (from cache) 167 silly pacote version manifest for eslint-plugin-react@7.4.0 fetched in 412ms 168 silly resolveWithNewModule eslint-plugin-react@7.4.0 checking installable status 169 http fetch GET 304 https://registry.npm.taobao.org/case-sensitive-paths-webpack-plugin 598ms (from cache) 170 silly pacote version manifest for case-sensitive-paths-webpack-plugin@2.1.1 fetched in 599ms 171 silly resolveWithNewModule case-sensitive-paths-webpack-plugin@2.1.1 checking installable status 172 silly pacote http://registry.npm.taobao.org/fsevents/download/fsevents-1.1.2.tgz extracted to /var/folders/09/wz7n0jm57595m97_zpcl7h6m0000gn/T/npm-2400-75ffb0fc/unpack-e2104430 by content address 367ms 173 silly addBundled read tarball 174 silly cleanup remove extracted module 175 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...ttachment":false,"tar' 175 verbose stack at JSON.parse (<anonymous>) 175 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/node_modules/json-parse-better-errors/index.js:7:17) 175 verbose stack at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/body.js:96:50) 175 verbose stack at <anonymous> 175 verbose stack at process._tickCallback (internal/process/next_tick.js:188:7) 176 verbose cwd /Users/shanshanxue/Documents/workspace/my-react-app 177 verbose Darwin 16.4.0 178 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts" 179 verbose node v9.2.0 180 verbose npm v5.5.1 181 error Unexpected end of JSON input while parsing near '...ttachment":false,"tar' 182 verbose exit [ 1, true ]

解决办法:

设置npm代理地址,命令如下:

npm config set registry http://registry.cnpmjs.org

之前一直用的淘宝npm代理

npm config set registry https://registry.npm.taobao.org

切换回来,就不报错。详细起因不明白。

补充:把npm版本降级,实测可以解决,可能5.0以上版本有微妙的问题
node v9.2.0
npm v5.5.1 上面是我本机当前的环境信息,可以把npm降级后试试,命令如下 npm i -g npm@4 

再补充

使用 yarn 安装
npm i -g yarn

转载于:https://www.cnblogs.com/shenlaiyaoshi/p/8472081.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值