简体   繁体   中英

React error with create-react-app command

I have been facing a weird situations while creating a react app via command line on windows 10. I get the following error when I run create-react-app command. I am using node v8.9.4 and npm v6.4.0.

Creating a new React app in D:\react\myreactapp. 

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 '...^1.0.1","line-numbers' 

npm ERR! A complete log of this run can be found in: 
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache\_logs\2018-08-26T11_04_03_908Z-debug.log 

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

Deleting generated file... package.json 
Deleting myreactapp / from D:\react 
Done.

It may have to do with the project name you gave it. Try using dragon-case, ie only lower case and hyphens. So instead of

$ create-react-native-app myApp 

use

$ create-react-native-app my-app

or from the error message, could it be that after the app name (myreactapp) you added a space and then pressed the back-slash instead of Enter, before pressing Enter again?

Also, try: npm cache clean --force

and if that doesn't do the trick: yarn cache clean

It may have been caused by a missing linebreak in the React-Native installation instructions in the Readme (that has been fixed since), between npm install and npm start causing users to do npm install npm start - which was installing npm itself with all its tests. See issue: https://github.com/facebook/react-native/issues/20015 .

In any case it would be good if you ran react-native info and told us the result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM