create-Vue-app创建项目报错SyntaxError: Unexpected end of JSON input while parsing near ‘…ttachment":false,"tar’
##SyntaxError: Unexpected end of JSON input while parsing near ‘…ttachment":false,"tar’
错误情况
执行 下面命令行时,报错
create-react-app my-react-app
npm错误日志
```javascript
× Install fail! SyntaxError: Unexpected end of JSON input (file: C:\Users\14408\Desktop\webpack\webpack_start2\node_modules\_json-loader@0.5.7@json-loader\package.json)SyntaxError: Unexpected end of JSON input (file: C:\Users\14408\Desktop\webpack\webpack_start2\node_modules\_json-loader@0.5.7@json-loader\package.json)
at JSON.parse (<anonymous>)
at Object.readJSON (C:\Users\14408\AppData\Roaming\npm\node_modules\cnpm\node_modules\npminstall\lib\utils.js:33:17)
at readJSON.next (<anonymous>)
at onFulfilled (C:\Users\14408\AppData\Roaming\npm\node_modules\cnpm\node_modules\co\index.js:65:19)
npminstall version: 3.27.0
rconfig=C:\Users\14408\.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=https://r.npm.taobao.org webpack@3.6.0 --save-dev
## 解决办法:
设置npm代理地址,命令如下:
> npm config set registry http://registry.cnpmjs.org
改回npm,只是设置代理就好了
一直用的淘宝npm代理,cnpm
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@版本号