Reactjs Express 应用程序 -Heroku 推送错误:“yarnPath”无法从“yarnrc.yml”读取文件

发布于 2025-01-13 09:36:55 字数 2767 浏览 3 评论 0原文

我已经部署了一个我正在工作的网站,它是 Heroku 的 Reactjs Express 应用程序。目前已部署 3 周。但是最近对应用程序进行了一些更改后,我无法将代码推送到heroku。我在进行推送时遇到错误。

$ git push heroku master
Enumerating objects: 912, done.
Counting objects: 100% (912/912), done.
Delta compression using up to 8 threads
Compressing objects: 100% (725/725), done.
Writing objects: 100% (742/742), 27.42 MiB | 2.69 MiB/s, done.
Total 742 (delta 160), reused 30 (delta 8), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        USE_YARN_CACHE=true
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=false
remote:
remote: -----> Build failed
remote:  !     The 'yarnPath' could not be read from the 'yarnrc.yml' file
remote:
remote:       It looks like 'yarnrc.yml' is missing the 'yarnPath' value, which is needed
remote:       to identify the location of yarn for this build.
remote:
remote:       To regenerate 'yarnrc.yml' with the 'yarnPath' value set, make sure Yarn 2
remote:       is installed on your local machine and set the version in your project
remote:       directory with:
remote:
remote:        $ yarn set version berry
remote:
remote:       Read more at the Yarn docs: https://yarnpkg.com/getting-started/install#per-project-install
remote:
remote:        https://devcenter.heroku.com/articles/nodejs-support
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 21afbb1f965651a191a2a03c3d0047685d8c76fc
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 21afbb1f965651a191a2a03c3d0047685d8c76fc
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to jithin-career.
remote:
To https://git.heroku.com/jithin-career.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/jithin-career.git'

一段时间以来我一直在努力寻找解决方案。提到的一些解决方案对我不起作用。有人可以帮我解决这个问题吗?

I had deployed a website I am working which is a Reactjs Express App to Heroku. It has deployed for 3 weeks now. But after making some changes to app recently I am not able to push the code to heroku. I am encountering an error when doing a push.

$ git push heroku master
Enumerating objects: 912, done.
Counting objects: 100% (912/912), done.
Delta compression using up to 8 threads
Compressing objects: 100% (725/725), done.
Writing objects: 100% (742/742), 27.42 MiB | 2.69 MiB/s, done.
Total 742 (delta 160), reused 30 (delta 8), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        USE_YARN_CACHE=true
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=false
remote:
remote: -----> Build failed
remote:  !     The 'yarnPath' could not be read from the 'yarnrc.yml' file
remote:
remote:       It looks like 'yarnrc.yml' is missing the 'yarnPath' value, which is needed
remote:       to identify the location of yarn for this build.
remote:
remote:       To regenerate 'yarnrc.yml' with the 'yarnPath' value set, make sure Yarn 2
remote:       is installed on your local machine and set the version in your project
remote:       directory with:
remote:
remote:        $ yarn set version berry
remote:
remote:       Read more at the Yarn docs: https://yarnpkg.com/getting-started/install#per-project-install
remote:
remote:        https://devcenter.heroku.com/articles/nodejs-support
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 21afbb1f965651a191a2a03c3d0047685d8c76fc
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 21afbb1f965651a191a2a03c3d0047685d8c76fc
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to jithin-career.
remote:
To https://git.heroku.com/jithin-career.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/jithin-career.git'

I have been trying to find a solution to this for some time. Some of the solutions which was mentioned didn't work for me. Can anyone please help me this issue?

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

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

发布评论

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

评论(2

简单 2025-01-20 09:36:55

我有类似的问题。
这是解决方案。

  1. 在本地,运行以下命令
yarn set version berry
  1. 激活 .gitignore 中的零安装
.yarn/*
!.yarn/cache
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions

或停用零安装

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
  1. yarn install 并应用安装。
  2. 将所有更改提交到 git 存储库。
  3. git push heroku main

更多信息请参考官方手册页。

https://devcenter.heroku。 com/articles/migration-to-yarn-2#make-changes-to-source-code

I had a similar problem.
Here is the solution.

  1. locally, run the following command
yarn set version berry
  1. activate Zero-Install in .gitignore
.yarn/*
!.yarn/cache
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions

or Deactivate Zero-Install

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
  1. yarn install and apply instllation.
  2. Commit all changes to git repogitory.
  3. git push heroku main

For more information, please refer to the official manual page.

https://devcenter.heroku.com/articles/migrating-to-yarn-2#make-changes-to-source-code

苏大泽ㄣ 2025-01-20 09:36:55

不幸的是,运行规范时,yarn 4.1.1(最新版本)不再包含 .yarnrc.yml 文件中的 yarnPath 属性。有关原因的更多信息,请参见:https://github.com/yarnpkg/berry/issues/4063< /a>.

我的解决方法是包含来自不同项目的这些内容,我有必要的 cjs 发布文件和yarnPath 属性,这样我的部署就可以工作。

对于任何可能需要帮助的人,我创建了一个存储库,为任何可能觉得有帮助的人提供必要的文件:https://github.com/pepefeliblu/yarn-path-workaround.git

我不认为这是最终的确定解决方案,但由于这似乎是最近的更改,这是可能的Heroku 团队目前还无法解决这个问题。

Unfortunately, yarn 4.1.1 (latests version) does not include the yarnPath property in the .yarnrc.yml file anymore when running the specs. More information on why here: https://github.com/yarnpkg/berry/issues/4063.

My workaround was to include these from a different project I had the necessary cjs release file and the yarnPath attribute so my deploy would work.

As for anyone who might need help, I have created a repo to provide the necessary files for anyone who might find it helpful: https://github.com/pepefeliblu/yarn-path-workaround.git

I don't consider this to be a final definitive solution, but as this seems to be a recent change, it is possible that the Heroku team has not been able to address this as for now.

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