简体   繁体   English

反应:404/运行`npm run build`后没有文件夹结构

[英]React: 404/No folder structure after running `npm run build`

I can access my index page perfectly with the following apache config我可以使用以下 apache 配置完美访问我的索引页面

    <VirtualHost *:443>
        ServerName MyReactAppSite

        DocumentRoot /var/www/sites/MyReactAppSite/client/build/

    </VirtualHost>

in my App.js folder I have the following code在我的 App.js 文件夹中,我有以下代码

<Route exact path="/home" component={Home} />

So after logging in app routes to http://MyReactAppSite/home所以登录应用程序后路由到http://MyReactAppSite/home

Works perfectly with >> npm run start与 >> npm run start完美配合

404 not found >> npm run build followed by serve -s build 404 未找到 >> npm run build后跟serve -s build

When I look inside the /build folder there is no /home folder so what is the proper way to get a production build of a React App.当我查看 /build 文件夹时,没有 /home 文件夹,那么获取 React 应用程序的生产版本的正确方法是什么。 I have read this whole page 2x https://create-react-app.dev/docs/deployment/ and can't seem to figure it out.我已经阅读了整页 2x https://create-react-app.dev/docs/deployment/并且似乎无法弄清楚。

In order to facilitate the REST attributes of my particular app I had to set up a .htaccess file to rout all request back into the index.html file created by my React App build.为了方便我的特定应用程序的 REST 属性,我必须设置一个 .htaccess 文件来将所有请求路由回由我的 React App 构建创建的 index.html 文件。

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteCond %{REQUEST_URI} !=/upload
  RewriteCond %{REQUEST_URI} !=/tmp
  RewriteRule ^ index.html [L]
</IfModule>

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

相关问题 运行 npm 运行构建后反应应用程序更改未更新 - React app changes not updaiting after running npm run build 运行“npm run build”后“sh: 1: react-scripts: not found” - "sh: 1: react-scripts: not found" after running "npm run build" npm 运行构建后反应空白页或404页,问题出在哪里? - React blank page or 404 page after npm run build, Where did the problem come from? 由于 react-router-dom 运行 npm 运行构建后反应空白页 - React blank page after running npm run build because of react-router-dom npm 运行 build React 后出现白屏 - White Screen after npm run build React React 应用程序在 `npm start` 期间工作,但在构建后返回 404 - The React App works during `npm start` but returns 404 after build 安装sass后在React中运行npm run build命令时出错 - Error while running npm run build command in react after installing sass 为基于 create-react-app 的项目运行 npm build 后,在运行时读取环境变量 - Reading environment variable in run time after running npm build for a create-react-app based project 运行“npm run build”后如何在 React 应用程序上编辑和显示更新 - How to edit and show updates on React app after running 'npm run build' 运行npm run deploy时找不到“ build”文件夹 - No “build” folder found when running npm run deploy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM