Heroku构建由于Yarn和npm lockfile冲突而失败 [英] Heroku build failing due to Yarn and npm lockfile conflict

查看:119
本文介绍了Heroku构建由于Yarn和npm lockfile冲突而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Im trying to deploy React Web app on Heroku using the 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'

由于使用npm,我做了rm并删除了纱线锁文件.仍然出现相同的错误.现在,当我实际执行rm yarn.lock时,在终端中找不到任何条目.为什么不知道Heroku CLI坚持认为我的目录中仍然有纱线锁文件.

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.

推荐答案

在将其推送到Heroku之前,您是否要提交回master分支?

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

对于我来说,最常见的情况是,当我进行代码更改然后"git push heroku master"更改时,会出现这样的问题,但是我的master分支尚未更新,因为我尚未提交本地更改.

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.

尝试

git commit -m 'some changes'

然后

git push heroku master

这篇关于Heroku构建由于Yarn和npm lockfile冲突而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆