我正在学习NodeJS,我要学习的课程有按项目分类的几个项目。我将所有项目都放在一个主文件夹下,该主文件夹也是git仓库。
主文件夹中的这些子文件夹中的每个子文件夹本身都是一个节点项目,带有中的package.json
相关子项及其相关性node_modules
。问题是当我尝试将其中一个文件夹(todo-api
)中的节点应用程序推送到heroku时,出现以下错误-
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to agile-forest-32749.
remote:
To https://git.heroku.com/agile-forest-32749.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/agile-forest-32749.git'
这是项目的目录结构-
我决定将todo-api
子文件夹全部重构为一个新项目,这一次向Heroku的推送就可以了-
我不明白为什么会收到“无默认语言”错误,尤其是当节点应用在两个地方都完全相同时。有什么想法吗?
Heroku有一组默认的buildpacks,在需要检测您的应用程序语言时使用。
为了进行检测,它将运行bin/detect
每个默认buildpack 的命令,直到其中一个返回0退出代码为止。
这是节点buildpack的命令。
如您所见,它要求a package.json
必须位于应用程序的根目录中,而不是子文件夹中。
这是导致构建失败的区别。您需要将应用程序放置在git存储库的根目录下。