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

问题描述 投票:0回答:2

我已经部署了一个我正在工作的网站,它是 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'

一段时间以来我一直在尝试寻找解决方案。提到的一些解决方案对我不起作用。谁能帮我解决这个问题吗?

reactjs express heroku heroku-cli
2个回答
0
投票

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

  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


0
投票

不幸的是,运行规范时,yarn 4.1.1(最新版本)不再在

yarnPath
文件中包含
.yarnrc.yml
属性。有关原因的更多信息,请参见此处:https://github.com/yarnpkg/berry/issues/4063

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

我不认为这是最终的解决方案,但由于这似乎是最近的变化,Heroku 团队可能无法解决这个问题。

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

© www.soinside.com 2019 - 2024. All rights reserved.