node.js - 由于 Yarn 和 npm 锁文件冲突,Heroku 构建失败

标签 node.js heroku server package-managers yarnpkg

我正在尝试使用 Heroku CLI 在 Heroku 上部署 React Web 应用程序。然而,当我运行时,

git push 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'

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

最佳答案

如果你使用 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

关于node.js - 由于 Yarn 和 npm 锁文件冲突,Heroku 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47238241/

相关文章:

python - 在 Heroku 中安装 Python 依赖项

node.js - 当我想要更多/全部时,Mongoose 将查询限制为 1000 个结果(从 2.6.5 迁移到 3.1.2)

javascript - 路线 ('next' )在 ExpressJS 中做什么?

javascript - 如何使用 JS 将文本文件转换为 CSV 文件,同时保持文本文件格式?

node.js - "Could not find a required file. Name: index.html"在Heroku上部署React应用程序时出错

ruby-on-rails - 错误-heroku "insecure world writable dir/var/psql_socket in PATH"

powershell - 如果使用率高于%PowerShell,则向用户发送电子邮件

php - 警告 : Creating default object from empty value in ($this)

android - 建立 Node.Js 本地服务器(localhost : 8888) on WiFi though WiFi Router (Passing it through LAN to WiFi Router)?

node.js - 使用 mysqljs 和存储过程发布后 insertId 返回 0