Heroku构建因纱线和NPM Lockfile冲突而失败
我正在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
如果您使用
npm
:如果使用
YARN
:If you use
npm
:If you use
yarn
:您是否要在将其推到Heroku之前就回到主人分支?
对于我来说,最常见的是,当我进行代码更改然后“ 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
then
删除Yarn.lock和Package-Lock.json之后:
这对我有用!
delete both yarn.lock and package-lock.json and after it:
that works for me!
我遇到了同样的问题,但是上述建议无济于事。我所做的是删除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.
我遇到了同样的问题,但是就我而言,我推动了包含包装锁的主分支。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
.如果使用NPM,请遵循以下内容:
If you use npm please follow this :
也有同样的问题。不确定在部署到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.还要检查您是否需要一个构建包来部署到Heroku。
需要添加buildpack
例如,对于流星,如果您有多个git应用程序,则
Also check if you need a buildpack for deploying to heroku.
For example for meteor you need to add a buildpack
if you have multiple apps for that git make sure to add
--app foobar
as your app name to your heroku command就我而言,我不得不结帐主分支并运行
GIT推动Heroku Main
。这解决了我的问题
In my case, I had to checkout main branch and run
git push heroku main
.this solved my problem