简体   繁体   English

无法使create-react-app正常工作

[英]Cannot get create-react-app to work

I am trying to get create-react-app to work. 我正在尝试使create-react-app正常工作。 Originally I had a React app working but decided to make it ES6+ syntax over ES5, which exploded on me. 最初,我有一个React应用程序,但是决定在ES5之上使它成为ES6 +语法,这让我大吃一惊。 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 我在服务器上工作,而不是在本地服务器上工作(如果有所不同。)第一次设置React时,我遵循的是https://tylermcginnis.com/react-js-tutorial-1-5-utilizing-webpack-and- babel-to-build-a-react-js-app /并可以正常工作,但是当我偶然发现https://egghead.io/lessons/react-react-fundamentals-development-environment-setup并决定尝试创建-反应应用内

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. 我按照说明进行操作(先运行npm create-react-app i -g然后运行create-react-app my-app 。当我进入CD时,我只发现了准系统package.json文件……我以为我本来应该得到一个不需要配置的入门结构...但是它只创建文件夹和package.json文件。我一直在努力地搜索,但似乎找不到类似问题的人。我们将不胜感激。

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. 除非我误会了,否则create-react-app的要点是避免不得不修改webpack.config.json,babel.rc或从头开始设置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. 我通过在服务器上创建一个交换文件(1024mb)解决了该问题,从而解决了该问题。 My server only had 512mb ram which I guess was not enough. 我的服务器只有512mb的ram,我想那还不够。 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. https://www.digitalocean.com/community/questions/how-to-change-swap-size-on-ubuntu-14-04是我遵循的指南,希望这对以后的工作有所帮助。

create-react-app uses a package called react-scripts as its backbone. create-react-app使用一个名为react-scripts的包作为其主干。 When you create an app using create-react-app , you get all the functionality that react-scripts provides you, including the following scripts: 使用create-react-app ,您将获得react-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. 如果您想查看应用程序的完整配置,可以使用npm run eject应用程序的抽象,并获取正在使用的所有实际文件和配置,以便您可以自己修改。 Keep in mind, once you run npm run eject , you can't go back to this simpler format (unless you recreate the app). 请记住,一旦运行npm run eject ,就无法返回这种更简单的格式(除非重新创建应用程序)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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