“在Heroku上为应用程序使用多个Buildpack时,没有为此应用程序检测到默认语言”
我在Heroku中部署了两个nodejs项目,每个项目都在自己的文件夹中 -
NodejsExpressApp1
和NodejsConsoleApp1
。
我在应用程序根目录中添加了Procfile
文件,其中包含以下内容 -
web: node NodejsExpressApp1/app.js
worker: node NodejsConsoleApp1/app.js
此外,我已将BUILD_DIR
配置var设置为NodejsExpressApp1
文件夹。
在当地一切正常。
下面显示了我在部署时获得的内容 -
c:\ExpressMultiProjectApp2>git push heroku master
Counting objects: 1506, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1401/1401), done.
Writing objects: 100% (1506/1506), 4.85 MiB | 92.00 KiB/s, done.
Total 1506 (delta 269), reused 0 (delta 0)
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
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to sheltered-mesa-74202.
remote:
To .git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '.git'`
谢谢!
回答如下:在app根目录下创建package.json文件后修复了该问题 -
{
"name": "nodejs-express-app1",
"version": "0.0.0",
"description": "Multiple Buildpacks App",
"author": { "name": "SimonBor" },
"dependencies": {
"express": "~4.9.0"
}
}
设置变量
BUILD_DIR
不是必需的步骤。
当然,它不是最佳实践解决方案,但它允许我继续开发。 我会更乐意寻求更好的解决方案。
最好的祝福!