我正在关注 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
我应该在这里做什么?任何帮助将不胜感激。
答案 0 :(得分:4)
我今天遇到了同样的问题。在我看来,问题与 knex 的版本与 nodejs 的版本不兼容有关。在进一步研究之后,Strapi 与 v.14 上的 nodejs 或 v.6 上的 npm 不兼容(Heroku 试图用 node v.15 构建我的 Strapi 应用程序)。为了解决这个问题,我更新了 package.json 文件以确保 Heroku 使用兼容的版本。这是我添加的内容,它对我有用,我希望它对你有用。
在 package.json 文件中,像这样更新 node 和 npm 的版本:
"engines": {
"node": "<=14.x.x",
"npm": "<=6.x.x"
}