构建失败后 React 站点上的错误 404。找不到文件

Error 404 on React site after a failed build. File cannot be found

我有一个 React 应用程序,它可以在我的开发环境中很好地构建和部署。现在我做了一些重构,仅限于移动一些文件、提交、测试和重新部署。在我部署到 productiong 的最新更改之后,发现在生产中我在访问该站点时得到了 404。 404 not found。我完全不知道可能是什么问题。

查看 bitbucket 管道我得到以下输出:

./src/pages/Home.jsx
Cannot find file '../components/narrative/Narrative' in './src/pages'.

现在,如果我查看“./src/pages/Home.jsx”,我可以看到我正在导入以下内容

import Narrative from "../components/narrative/Narrative"

并且该文件确实存在:

管道的完整输出在这里:

root@ubuntu-web:~/eg-web# npm run build
> refgator-web@0.1.0 build /root/eg-web
> react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
Failed to compile.
./src/pages/Home.jsx
Cannot find file '../components/narrative/Narrative' in './src/pages'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! refgator-web@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the refgator-web@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-02-16T10_23_04_697Z-debug.log

如果我转到生产服务器,这是最新的错误日志:

这实际上是由文件夹名称引起的,因为它在本地称为 narrative。在回购协议上它是 Narrative

我在这个答案的帮助下更改了这个 In a Git repository, how to properly rename a directory?