Reactjs Express App -Heroku 推送错误:无法从'yarnrc.yml'文件中读取'yarnPath'



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

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

我也遇到了类似的问题。这是解决方案。

  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-regitory
  3. git push heroku main

有关更多信息,请参阅官方手册页面。

https://devcenter.heroku.com/articles/migrating-to-yarn-2#make-更改源代码

最新更新