推向Heroku时未发现错误

发布于 2025-01-22 12:56:24 字数 817 浏览 1 评论 0原文

我知道这个问题已经增加了无数次,但是我尝试了几乎所有可用的解决方案,但没有成功。问题是我有能力毫无问题地将其部署到Github页面上,但是Heroku提到我有一些路由问题。

在最近的一期之后,Heroku删除了Github与Heroku的集成,我一直在推动代码时遇到了困难。最初,我的网站正常工作,并通过GitHub自动部署。但是,当我尝试手动推动通过:

$ git add .
$ git commit -am "make it better"
$ git push heroku master

我面临此错误:

Module not found: Error: Can't resolve './pages/MainPage' in '/tmp/build_8986ef5f/src'

我尝试删除此页面,而错误只会更改为另一个无法解决路径错误。

我的文件目录是:

- build
- node_modules
- public
- src
    - pages
        - MainPage.js
        - SecondPage.js
        - ...
    - App.js
    - index.js
.gitignore
package-lock.json
package.json

在app.js文件中,我通过相对路径通过:

import Home from './pages/MainPage';

我的相对路径有问题吗?自从通过github部署以来,我没有更改结构,所以我不知道错误是什么。

I understand that this issue has been raised numerous times, but I have tried almost all solutions available with no success. The thing is that I am capable of deploying to GitHub pages with no problem, but Heroku mentions I have some routing issue.

After the recent issue whereby Heroku removed Github integration with Heroku, I have been having trouble pushing code. Initially, my website worked fine, with automatic deployment via Github. However, when I try manually pushing via:

$ git add .
$ git commit -am "make it better"
$ git push heroku master

I am facing this error:

Module not found: Error: Can't resolve './pages/MainPage' in '/tmp/build_8986ef5f/src'

I have tried removing this page, and the error will just change to another can't resolve path error.

My file directory is:

- build
- node_modules
- public
- src
    - pages
        - MainPage.js
        - SecondPage.js
        - ...
    - App.js
    - index.js
.gitignore
package-lock.json
package.json

Within the App.js file, I import the library through a relative path via:

import Home from './pages/MainPage';

Is there something wrong with my relative pathing? I have not changed the structure since deploying via Github so I don't know what's the error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

身边 2025-01-29 12:56:24

我发现了错误。显然,部署到Github已导致某些对病例敏感的命名出错。例如,尽管我将其部署为主页,但由于某些原因,它被部署为主页。

这导致无法找到文件路径。

我使用:

heroku run bash

找出命名约定的错误。为了修复它,我将所有受影响的文件夹删除了错误的外壳部署,进行了更改,然后将其读取并重新部署了它。我这样做后起作用。

I've found out the error. Apparently deploying to Github had resulted in some case-sensitive naming to go wrong. E.g. although I was deploying it as MainPage, it was deployed as mainpage for some reason.

This had resulted in being unable to find the file path.

I used:

heroku run bash

To figure out the error of naming convention. To fix it, I removed all affected folders with wrong casing deployment, committed changes, then readded them in and redeployed it. It worked after I did this.

以歌曲疗慰 2025-01-29 12:56:24

谢谢@dfwgwefewfwe!我没有足够的声誉来对他们的帖子发表评论,但这肯定为我固定了。

只是为了其他可能坚持的其他信息添加一些额外的信息:

我的问题是,我有一些资产在文件夹中,例如

Equipment
  /hands
    /gloves1.png
    /gloves2.png
  /feet
    /boots1.png
    /boots2.png

使事情变得更加一致,我只是将第一封信大写了,

我跑了命令

heroku run bash

并能够找到已更名的文件夹,并且仍在旧版本中。

因此,回到本地副本上,我将整个设备文件夹移至另一个位置,删除了对代码中资产的任何引用,然后将其推到了Heroku。

现在,该设备文件夹已在服务器上删除,然后我能够恢复我的最后一个git提交,并准确地推动我试图推动的东西并奏效。

我希望这对别人有帮助!

Thank you @dfwgwefewfwe! I don't have enough reputation to comment on their post, but it definitely fixed it for me.

Just to add some extra information though for others that may be stuck with it:

My issue was that I had some assets that were in folders such as

Equipment
  /hands
    /gloves1.png
    /gloves2.png
  /feet
    /boots1.png
    /boots2.png

To make things more consistent, I just capitalized the first letters to be Hands and Feet

I ran that command

heroku run bash

and was able to find those folders that had been renamed, and they were still in their old version.

So back on my local copy, I moved the whole Equipment folder to another location, removed any references to the assets in the code, and pushed that up to heroku.

Now the Equipment folder was removed on the server, then I was able to revert my last git commit and push exactly what I was trying to push before and it worked.

I hope that this helps someone else!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文