执行create-react-app会出错

时间:2018-06-18 17:10:07

标签: reactjs npm

运行create-react-app my-new-app时出现以下错误。我的npm版本是6.1.0,节点版本是8.11.3

$ create-react-app my-new-app

Creating a new React app in C:\Users\home\Desktop\Web Development\7. 
React\my-new-app.

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

npm ERR! Unexpected end of JSON input while parsing near '...ectories":
{},"dist"                                                                     
:{'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\home\AppData\Roaming\npm-cache\_logs\2018-06-
16T12_46_38_1                                                                     
22Z-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-new-app / from C:\Users\home\Desktop\Web Development\7. React
Done.

2 个答案:

答案 0 :(得分:2)

尝试以下命令:

npm cache clean --force

答案 1 :(得分:0)

也许你有一个过时的create-react-app 版本。

如果你有npm 6,那么你也有 npx 。使用npx你可以这样做:

npx create-react-app my-new-app

它将使用最新的create-react-app,即使你没有安装它。 查看documentation

相关问题