skip to Main Content

enter image description here

try to do with react and local host but it is showing direct file not website. please help me out. I am stuck from last 3-4 hours still can’t find the solution. waiting for you guy’s to help me out with this problem.

3

Answers


  1. Of course, since you don’t describe here how you’re trying to host your website, I can only speculate.

    If you are using a web server, such as Apache, then you need to point the document root to the public folder.

    this is of course also true for all other webservers you might use.

    However, from your picture it looks like you are trying to host a development version. Keep in mind, before you use an app productively, you should create an appropriate build.

    You can do this with

    npm run build
    

    If you really want to host your development version on the server, you will of course have to start this server with npm start accordingly

    Login or Signup to reply.
  2. It seems that you are trying to run liveserver in VS code or similar. Live server does not build your code. It just serves things as they are. You can use live server after building your project or for rendering html files.

    For running the React project, you need to run npm run start or npm run dev or similar command. You can find that out in your package.json file.

    Login or Signup to reply.
  3. For react, you’ll have to run a npm script (which are given in your package.json file) to host it on your localhost, which usually is

    npm run dev
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search