Heroku构建因纱线和NPM Lockfile冲突而失败

发布于 2025-01-22 04:44:55 字数 1936 浏览 3 评论 0原文

我正在尝试使用Heroku CLI在Heroku上部署React Web应用程序。但是当我跑步时,

git推动Heroku Master

从我的项目文件夹中推送出一个错误,因为

Counting objects: 213, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (212/212), done.
Writing objects: 100% (213/213), 515.89 KiB | 0 bytes/s, done.
Total 213 (delta 40), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote: 
remote: -----> Build failed
remote:  !     Two different lockfiles found: package-lock.json and 
yarn.lock
remote: 
remote:        Both npm and yarn have created lockfiles for this 
application,
remote:        but only one can be used to install dependencies. 
Installing
remote:        dependencies using the wrong package manager can 
result in missing
remote:        packages or subtle bugs in production.
remote: 
remote:        - To use npm to install your application's 
dependencies please delete
remote:          the yarn.lock file.
remote: 
remote:          $ git rm yarn.lock
remote: 
remote:        - To use yarn to install your application's 
dependences please delete
remote:          the package-lock.json file.
remote: 
remote:          $ git rm package-lock.json
remote:     
remote:        https://kb.heroku.com/why-is-my-node-js-build-
failing-because-of-conflicting-lock-files
remote: 
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to MyAPP.
 remote: 
 To https://git.heroku.com/MyAPP.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 
https://git.heroku.com/MyAPP.git'

我使用了rm并删除了纱线锁定文件,因为我使用了npm。仍然出现同样的错误。现在,当我实际上做rm yarn.lock时,我会在终端中找到一个条目。 IDK为什么Heroku CLI坚持我在目录中仍然有纱线锁定文件。

I'm trying to deploy a React Web app on Heroku using the Heroku CLI. However when I run,

git push heroku master

from my project folder it throws an error as:

Counting objects: 213, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (212/212), done.
Writing objects: 100% (213/213), 515.89 KiB | 0 bytes/s, done.
Total 213 (delta 40), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote: 
remote: -----> Build failed
remote:  !     Two different lockfiles found: package-lock.json and 
yarn.lock
remote: 
remote:        Both npm and yarn have created lockfiles for this 
application,
remote:        but only one can be used to install dependencies. 
Installing
remote:        dependencies using the wrong package manager can 
result in missing
remote:        packages or subtle bugs in production.
remote: 
remote:        - To use npm to install your application's 
dependencies please delete
remote:          the yarn.lock file.
remote: 
remote:          $ git rm yarn.lock
remote: 
remote:        - To use yarn to install your application's 
dependences please delete
remote:          the package-lock.json file.
remote: 
remote:          $ git rm package-lock.json
remote:     
remote:        https://kb.heroku.com/why-is-my-node-js-build-
failing-because-of-conflicting-lock-files
remote: 
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to MyAPP.
 remote: 
 To https://git.heroku.com/MyAPP.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 
https://git.heroku.com/MyAPP.git'

I did rm and removed the yarn lock file since I use npm. Still the same error shows up. Now when I actually do rm yarn.lock I get a no entry found in the terminal. Idk why Heroku CLI insists that I still have yarn lock file in the directory.

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

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

发布评论

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

评论(9

橘和柠 2025-01-29 04:44:55

如果您使用npm

git rm yarn.lock
git commit -m "Remove yarn lock file"
git push heroku master

如果使用YARN

git rm package-lock.json
git commit -m "Remove npm lock file"
git push heroku master

If you use npm:

git rm yarn.lock
git commit -m "Remove yarn lock file"
git push heroku master

If you use yarn:

git rm package-lock.json
git commit -m "Remove npm lock file"
git push heroku master
も让我眼熟你 2025-01-29 04:44:55

您是否要在将其推到Heroku之前就回到主人分支?

对于我来说,最常见的是,当我进行代码更改然后“ git push heroku master”时会出现这种问题,但是我的主人分支尚未更新,因为我尚未实施本地更改。

尝试

git commit -m 'some changes'

然后

git push heroku master

Are you committing back to your master branch before pushing it up to Heroku?

Most often for me, problems like this arise when I make a code change and then 'git push heroku master' but my master branch has not been updated as I haven't yet committed my local changes.

Try

git commit -m 'some changes'

then

git push heroku master
懵少女 2025-01-29 04:44:55

删除Yarn.lock和Package-Lock.json之后:

git add --all 
git commit -a -m "Delete yarn lock and package lock"
git push 
git push heroku master

这对我有用!

delete both yarn.lock and package-lock.json and after it:

git add --all 
git commit -a -m "Delete yarn lock and package lock"
git push 
git push heroku master

that works for me!

我们只是彼此的过ke 2025-01-29 04:44:55

我遇到了同样的问题,但是上述建议无济于事。我所做的是删除yarn.lock(git rm yarn.lock),错误消失了。

I had the same problem, but the above suggestions didn't help. What I did was to delete yarn.lock (git rm yarn.lock) and the error was gone.

彡翼 2025-01-29 04:44:55

我遇到了同样的问题,但是就我而言,我推动了包含包装锁的主分支。JSON和YARN.LOCK。我通过使用命令git推动Heroku Branch-name:Master来修复此问题。

I had the same issue, but in my case I was pushing the master branch which contained both package-lock.json and yarn.lock. I fixed this by using the command git push heroku branch-name:master.

给我一枪 2025-01-29 04:44:55

如果使用NPM,请遵循以下内容:

rm yarn.lock
git add .
git commit -m 'remove yarn.lock file'
git push origin
git push heroku origin

If you use npm please follow this :

rm yarn.lock
git add .
git commit -m 'remove yarn.lock file'
git push origin
git push heroku origin
月依秋水 2025-01-29 04:44:55

也有同样的问题。不确定在部署到Heroku时如何重现包装锁,但这似乎正在发生。尝试创建一个.NPMRC文件,并添加package-lock = false这为我解决了问题。

Had the same issue. Not sure how package-lock is being recreated upon deploying to heroku but thats what seems to be happening. Try creating a .npmrc file and adding package-lock=false This fixed the issue for me.

深居我梦 2025-01-29 04:44:55

还要检查您是否需要一个构建包来部署到Heroku。

需要添加buildpack

heroku buildpacks:set https://github.com/AdmitHub/meteor-buildpack-horse.git

例如,对于流星,如果您有多个git应用程序,则

Also check if you need a buildpack for deploying to heroku.

For example for meteor you need to add a buildpack

heroku buildpacks:set https://github.com/AdmitHub/meteor-buildpack-horse.git

if you have multiple apps for that git make sure to add --app foobar as your app name to your heroku command

早乙女 2025-01-29 04:44:55

就我而言,我不得不结帐主分支并运行
GIT推动Heroku Main
这解决了我的问题

In my case, I had to checkout main branch and run
git push heroku main.
this solved my problem

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