create-react-app my-app 出错

版权声明:转载请注明出处 https://blog.csdn.net/qq799028706/article/details/85316528

我的环境:
win10
node v10.13.0
npm 6.4.1

出现的错误:

$ create-react-app my-app

Creating a new React app in D:\code\react\my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\1\AppData\Roaming\npm-cache\_logs\2018-12-27T13_06_47_206Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.

Deleting generated file... package.json
Deleting my-app/ from D:\code\react
Done.

谷歌了一下解决方案,npm装的太慢,把npm换成cnpm就行了

我之前创建错误的命令是

$ npm install -g create-react-app
$ create-react-app my-app
$ cd my-app/
$ npm start

然后使用了了淘宝的镜像就成功安装了

$ npm install -g cnpm --registry=https://registry.npm.taobao.org
$ cnpm install -g create-react-app
$ create-react-app my-app
$ cd my-app/
$ npm start

猜你喜欢

转载自blog.csdn.net/qq799028706/article/details/85316528