首页 > 解决方案 > Heroku 未检测到 Node.js 应用程序

问题描述

我在 Visual Studio 中创建了一个小站点,并使用了 Node.js 和 Express。我可以通过 Visual Studio 和 Heroku 本地网络访问它。但是,当尝试将其推送到 Heroku 时,出现错误:Application not supported by 'heroku/nodejs' buildpack

我通读了 Heroku 提供的文档,但没有找到任何解决方案。

ERROR: Application not supported by 'heroku/nodejs' buildpack
remote:  !
remote:  !     The 'heroku/nodejs' buildpack is set on this application, but was
remote:  !     unable to detect a Node.js codebase.
remote:  !
remote:  !     A Node.js app on Heroku requires a 'package.json' at the root of
remote:  !     the directory structure.
remote:  !
remote:  !     If you are trying to deploy a Node.js application, ensure that this
remote:  !     file is present at the top level directory. This directory has the
remote:  !     following files:
remote:  !
remote:  !     Portfolio/
remote:  !     Portfolio.sln
remote:  !
remote:  !     If you are trying to deploy an application written in another
remote:  !     language, you need to change the list of buildpacks set on your
remote:  !     Heroku app using the 'heroku buildpacks' command.
remote:  !
remote:  !     For more information, refer to the following documentation:
remote:  !     https://devcenter.heroku.com/articles/buildpacks
remote:  !     https://devcenter.heroku.com/articles/nodejs-support#activation

标签: node.jsheroku

解决方案


看看这个错误信息。

Heroku 上的 Node.js 应用程序在目录结构的根目录中需要一个“package.json”。

您的 package.json 是否在根目录中?


推荐阅读