D
D
Delerom2020-08-15 18:43:56
JavaScript
Delerom, 2020-08-15 18:43:56

Installing react application on hosting?

Good day. I bought a themeforest landing on react (webpack builder). I deployed everything on the local, everything works through localhost: 3000, made all the necessary changes, but how to upload it all to the hosting caught a dead end.

I do the following actions (locally):

npm run build --prod

Further, the following script comments (replaced mydomen with my domain):

The project was built assuming it is hosted at mydomen.ru .
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

serve -s build

Find out more about deployment here:

https://bit.ly/CRA-deploy

The built folder with the project appears, but when opening index.html, a white screen appears. I tried to write serve -s build and it says "serve : Cannot load file C:\Users\38066\AppData\Roaming\npm\serve.ps1 because scripting is disabled on this system."

Can you please advise where should I put this? on which host, can you run? Confused. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LoveCode &Coffe, 2020-08-15
@Delerom

You can link to the template. It may be that the template is not written in pure react, but for example using ssr or static generation.
Hosting does not allow you to execute the server team. Because you don't have vps. Your hosting type does not support node .js
Or maybe you do not need a server, again you need to know what your template is written on.
Then you need to locally build the project on your computer with npm run build or yarn build . And upload ONLY the contents of the build folder to the hosting. Well, then make the settings in accordance with your hosting. (Link a domain, etc.)

M
McBernar, 2020-08-15
@McBernar

1. You need a server. Like static react doesn't work.
That is, these files will not work locally.
2. I can assume that you still need htaccess on the hosting, which will redirect all requests to index if you have more than one page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question