heroku - Strapi + Heroku 部署失败 :npm ERR! 代码 ERESOLVE

标签 heroku knex.js strapi

我正在关注 this tutorial将 Strapi 应用程序部署到 Heroku。

我已设置为从我的 Github 存储库自动部署。

推送到 Github 后,我收到构建失败的通知,并显示以下消息。

构建日志

-----> Building on the Heroku-20 stack
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  >=10.16.0 <=14.x.x
       engines.npm (package.json):   >=6.0.0
       
       Resolving node version >=10.16.0 <=14.x.x...
       Downloading and installing node 14.15.4...
       Bootstrapping npm >=6.0.0 (replacing 6.14.10)...
       npm >=6.0.0 installed
       
-----> Installing dependencies
       Installing node modules (package.json)
       npm ERR! code ERESOLVE
       npm ERR! ERESOLVE unable to resolve dependency tree
       npm ERR! 
       npm ERR! While resolving: drkang-strapi@0.1.0
       npm ERR! Found: knex@0.19.5
       npm ERR! node_modules/knex
       npm ERR!   knex@"<0.20.0" from the root project
       npm ERR! 
       npm ERR! Could not resolve dependency:
       npm ERR! peer knex@"^0.20.0" from strapi-connector-bookshelf@3.4.6
       npm ERR! node_modules/strapi-connector-bookshelf
       npm ERR!   strapi-connector-bookshelf@"3.4.6" from the root project
       npm ERR! 
       npm ERR! Fix the upstream dependency conflict, or retry
       npm ERR! this command with --force, or --legacy-peer-deps
       npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
       npm ERR! 
       npm ERR! See /tmp/npmcache.9OnCF/eresolve-report.txt for a full report.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.9OnCF/_logs/2021-02-04T02_14_54_807Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Dangerous semver range (>) in engines.node
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

我应该在这里做什么?任何帮助将不胜感激。

最佳答案

我今天遇到了同样的问题。在我看来,问题与 knex 版本与 nodejs 版本不兼容有关。在深入研究之后,Strapi 与 v.14 上的 nodejs 或 v.6 上的 npm 不兼容(Heroku 试图使用节点 v.15 构建我的 Strapi 应用程序)。为了解决这个问题,我更新了 package.json 文件以确保 Heroku 使用兼容的版本。这是我添加的,它对我有用,我希望它对你有用。

在 package.json 文件中,像这样更新 node 和 npm 的版本:

"engines": {
  "node": "<=14.x.x",
  "npm": "<=6.x.x"
}

关于heroku - Strapi + Heroku 部署失败 :npm ERR! 代码 ERESOLVE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66038828/

相关文章:

mysql - ClearDB 自增

java - 当我在源中使用 try catch 时,-source 1.5 中不支持 try-with-resource 错误

javascript - Node.js 数据表编辑器 - 多列的自定义/唯一验证

database - 在不丢失数据的情况下更新 Knex.js 表

socket.io - 如何在 Strapi 服务器上设置套接字连接

ssl - 为 strpi 项目运行 npm i 时证书链中的自签名证书

database - 什么是数据库缓存以及如何使用它?

ruby-on-rails-3 - PGError : Error: column of relation does not exist

mysql - 如果数据库连接关闭或数据库服务器关闭立即执行查询会发生什么

content-management-system - 什么是 Strapi 中的 CollectionType、Category 和 Component