Reputation: 633
I am trying to deploy my app to heroku and I keep getting this error message saying that it "failed to detect app matching ......." and the push was rejected. I followed the way it said on the heroku website and I keep getting stuck on only that git push heroku master part I have tried doing some research I couldn't find a solution.
{
"name": "home-automation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server/server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.3",
"johnny-five": "^0.11.3",
"socket.io": "^2.0.3"
}
}
Server.js
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var express = require("express");
var five = require("johnny-five");
var board = new five.Board({port:"COM4"});
const port = process.env.PORT || 3000;
app.use(express.static("public"))
io.on('connection', function (socket) {
console.log("New User Connected")
board.on("ready", function(){
socket.on("turnLightOn", function(data){
var led = new five.Led({
pin:"13"
});
if(data.status){
led.on();
}else{
led.off();
}
})
})
});
server.listen(port, function(){
console.log("Listening on port 3000")
});
index.js
var socket = io();
$("#toggle-light").on("click", function(){
$("#led").toggle();
if($("#led").css("display") == "none"){
var status = false
}else{
var status = true
}
socket.emit("turnLightOn", {
status
})
})
index.html
<html>
<head>
<title>Home Automation</title>
</head>
<body>
<h1>Home Automation</h1>
<button id="toggle-light">Toggle Light</button>
<div id="led" style="width:100px; height:100px; background:yellow;"></div>
<p id="moistureLevel"></p>
<script src="/socket.io/socket.io.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="/js/index.js"></script>
</body>
</html>
Upvotes: 0
Views: 87
Reputation: 82
This means that a package.json file isn't checked into the root of your git project, so Heroku is detecting that it isn't a Node.js app. You can see this locally:
git show master:package.json
To fix it, you'll want to be sure there is a package.json in the root of your project (where there is also a .git directory), and add it to git:
git add package.json
git commit -m 'track package.json'
The phrasing ('failed to detect set buildpack') could be improved. It should probably say 'failed to detect Node.js app'. When the buildpack's "detect" script is run (https://github.com/heroku/heroku-buildpack-nodejs/blob/master/bin/detect), it looks for a package.json file to verify that there's a node app available to build.
Upvotes: 1