2017-11-11 99 views
1

我試圖使用CLI在Heroku上部署React Web應用程序。由於Yarn和npm鎖定文件衝突導致Heroku構建失敗

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:然而,當我運行,

 git push heroku master 

從我的項目文件夾,它拋出一個錯誤。仍然出現同樣的錯誤。現在,當我真正做到yarn.lock時,我在終端中找不到任何條目。 Idk爲什麼Heroku CLI堅持我目錄中仍然有紗線鎖定文件。

回答

3

在將其推向Heroku之前,您是否承諾回到主分支?

對我來說,最常見的問題是當我更改代碼然後'git push heroku master'但我的主分支還沒有更新,因爲我還沒有提交我的本地更改。

嘗試

git commit -m 'some changes' 

然後

git push heroku master 
+0

爲什麼git-push會關心未提交的更改?我認爲它應該有或沒有**「一些改變」。** – joshuamabina

0

有同樣的問題。不知道如何在部署到heroku時重新創建包鎖,但那似乎正在發生。嘗試創建.npmrc文件並添加package-lock=false這解決了我的問題。

相關問題