简体   繁体   中英

Cannot get create-react-app to work

I am trying to get create-react-app to work. Originally I had a React app working but decided to make it ES6+ syntax over ES5, which exploded on me. After several hours of debugging I decided to start over and deleted everything.

I am working on a server, not locally (if that makes a difference.) The first time I set up React I followed https://tylermcginnis.com/react-js-tutorial-1-5-utilizing-webpack-and-babel-to-build-a-react-js-app/ and got something working but when I stumbled on https://egghead.io/lessons/react-react-fundamentals-development-environment-setup and decided to try create-react-app

I followed the instructions (ran npm create-react-app i -g then create-react-app my-app . When I cd'd in, I found only a barebones package.json file… I thought I was supposed to get essentially a starter structure no config needed... but it only creates the folder and the package.json file. I have been googling hard but cannot seem to find someone with a similar problem. Any help would be GREATLY appreciated.

Unless I misunderstood, the point of create-react-app was to avoid having to tinker with webpack.config.json, babel.rc, or setting up from scratch the package.json. Am I missing something?

So it turns out the issue was my digital ocean droplet did not have enough ram to process the command in question. I solved the issue by creating a swapfile on my server (1024mb) and that solved the issue. My server only had 512mb ram which I guess was not enough. https://www.digitalocean.com/community/questions/how-to-change-swap-size-on-ubuntu-14-04 is the guide I followed, hope this helps somebody down the road.

create-react-app uses a package called react-scripts as its backbone. When you create an app using create-react-app , you get all the functionality that react-scripts provides you, including the following scripts:

npm run start
npm run build
npm run test
npm run eject

All of the actual configuration and dependencies are intentionally hidden to keep things simple. If you would like to see the full configuration of the app, you can use npm run eject to eject the abstraction of the app and get all the actual files and config it's using so you can make modifications of your own. Keep in mind, once you run npm run eject , you can't go back to this simpler format (unless you recreate the app).

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