create-react-app

Why do I need a server with create-react-app

不羁岁月 提交于 2021-02-19 03:05:27
问题 I recently created a website with create-react-app. Since this is not a web app, why do I need a server to see it? I tried to open the index file in build folder but it doesn't work unless I'm serving it from a server. 回答1: You can set the homepage root url in the package.json file e.g. { ..., "homepage":"file:///<path to build directory" } npm run build This will now find the static content in the build directory from the file system without a server. 来源: https://stackoverflow.com/questions

Why do I need a server with create-react-app

﹥>﹥吖頭↗ 提交于 2021-02-19 03:05:02
问题 I recently created a website with create-react-app. Since this is not a web app, why do I need a server to see it? I tried to open the index file in build folder but it doesn't work unless I'm serving it from a server. 回答1: You can set the homepage root url in the package.json file e.g. { ..., "homepage":"file:///<path to build directory" } npm run build This will now find the static content in the build directory from the file system without a server. 来源: https://stackoverflow.com/questions

React Router routes not working on nginx create-react-app

拜拜、爱过 提交于 2021-02-18 21:12:07
问题 I'm using "react-router-dom": "^4.2.2" . If I test on localhost:3000/second it works perfectly. When I upload this on ubuntu server with nginx and I try www.website.com , it works . When I try to use www.website.com/second it gives me 404 not found . I'm using create-react-app . app.js class TestRoutes extends React.Component{ constructor(props){ super(props); } render(){ return(<React.Fragment> <BrowserRouter> <Switch> <Route exact path='/' component={MainPage}/> <Route path='/second'

React axios calls to Express API in Heroku deployment

ぃ、小莉子 提交于 2021-02-18 08:39:18
问题 I have a React todo app I built using create-react-app and I built a simple express server to query mongoDB to get all the appointment objects. It works just as expected when I am running it on my machine. The front end spins up on localhost:3000 and the server on localhost:3001 . I use axios to make a get request to localhost:3000/api/appointments to load all the appointments into the App.js state. I uploaded it to Heroku and I got a CORS error on the request. After that, I tried to just use

Problem with Visual Studio Code using “react-jsx” as jsx value with create-react-app

不羁岁月 提交于 2021-02-15 12:07:13
问题 I'm struggling with following "error" in VSCode : Argument for '--jsx' option must be: 'preserve', 'react-native', 'react' Hence, react-scripts (create-react-app) automatically sets the jsx key to react-jsx value, when react value seems to work. Actually, the code works perfectly and displays the page I want, but the IDE is underlining kinda everything as errors, saying : Cannot use JSX unless the '--jsx' flag is provided. Here is my tsconfig.json : { "compilerOptions": { "target": "es5",

Problem with Visual Studio Code using “react-jsx” as jsx value with create-react-app

时光毁灭记忆、已成空白 提交于 2021-02-15 12:03:21
问题 I'm struggling with following "error" in VSCode : Argument for '--jsx' option must be: 'preserve', 'react-native', 'react' Hence, react-scripts (create-react-app) automatically sets the jsx key to react-jsx value, when react value seems to work. Actually, the code works perfectly and displays the page I want, but the IDE is underlining kinda everything as errors, saying : Cannot use JSX unless the '--jsx' flag is provided. Here is my tsconfig.json : { "compilerOptions": { "target": "es5",

create-react-app | Is it possible to serve a file from backend instead of serving index.html when a browser connect to app

孤人 提交于 2021-02-11 15:08:34
问题 I have been trying to enable SSL on my MERN heroku-deployed app. I have been stuck at this step far more than necessary: I am following this tutorial to set-up SSL certificate on my website. After, generating the certificate using this command locally: sudo certbot certonly --manual I was asked to do this by the terminal: Create a file containing just this data: dC9Ry5Ps_qgkOheuWnxCXFobim8vshqMqbDC9FQS4ic.noFTXhkC3HFnZ-RC9djrM6FpWGRy2AFSB17xz59apDA And make it available on your web server at

create-react-app | Is it possible to serve a file from backend instead of serving index.html when a browser connect to app

淺唱寂寞╮ 提交于 2021-02-11 15:05:15
问题 I have been trying to enable SSL on my MERN heroku-deployed app. I have been stuck at this step far more than necessary: I am following this tutorial to set-up SSL certificate on my website. After, generating the certificate using this command locally: sudo certbot certonly --manual I was asked to do this by the terminal: Create a file containing just this data: dC9Ry5Ps_qgkOheuWnxCXFobim8vshqMqbDC9FQS4ic.noFTXhkC3HFnZ-RC9djrM6FpWGRy2AFSB17xz59apDA And make it available on your web server at

Maximum call stack size exceeded while installing create react app on Linux

◇◆丶佛笑我妖孽 提交于 2021-02-11 14:26:34
问题 I have Linux with node - 12.4.0, npm - 6.9.0, npx - 6.9.0. I ran command npx create-react-app cra And getting following result: Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts... npm ERR! Maximum call stack size exceeded Aborting installation. npm install --save --save-exact --loglevel error react react-dom react-scripts has failed. The log says the error starts here: 27623 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9

Problem with NPX create-react-app. Keeps getting stuck at “Found 0 Vulnerabilties”

故事扮演 提交于 2021-02-11 14:09:39
问题 So I am trying to create a new React project using npx create-react-project but it keeps getting stuck after downloading the packages. So far the folder only contains the node modules and the 2 package.json files. The create-react-app goes well until it reaches found 0 vulnerabilities. I have done this in different folders and different hard drives but the same result. It just doesn't go further. I also deleted my previous global create-react-app installation but this didn't make a difference