我非常不熟悉部署过程以及如何解释Heroku上的构建日志。我正在尝试部署Phoenix Elixir应用程序,并且已经按照https://hexdocs.pm/phoenix/heroku.html概述的过程进行了。但是,我的构建日志中出现以下错误:
npm ERR! Linux 4.4.0-1062-aws
npm ERR! argv "/tmp/build_cb2fdf13a1883f06eae3f7c5297f7b64/.heroku/node/bin/node" "/tmp/build_cb2fdf13a1883f06eae3f7c5297f7b64/.heroku/node/bin/npm" "run" "deploy"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! @ deploy: `webpack --mode production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ deploy script 'webpack --mode production'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --mode production
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_cb2fdf13a1883f06eae3f7c5297f7b64/assets/npm-debug.log
我已按照日志建议将其更新到最新版本的node.js和npm。
谢谢!
答案 0 :(得分:1)
问题不在于您本地拥有的节点版本。如果查看日志,则表明 heroku 正在尝试使用节点v6.9.2。那是节点的真正旧版本,将无法正常工作。您需要使用heroku-buildpack-phoenix-static,以便可以定义heroku尝试使用的节点版本。添加带有cli的buildpack:
$ heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
然后在项目根目录中创建文件phoenix_static_buildpack.config。在该文件中,定义要使用的节点版本:
node_version=12.18.1
这将告诉heroku使用该版本的节点。之后,尝试重新部署,该问题应得到解决。
如果您还有其他问题,请查看有关部署到heroku的phoenix文档。它具有许多有用的信息: https://hexdocs.pm/phoenix/heroku.html