0

enter image description hereenter image description hereI 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. enter image description here

{
  "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>

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

8 Comments

That did help with deploying to heroku and but I get an application error which referred me to my build log (build log too long for comment)
maybe you can show me a liitle bit of it like " Error: Cannot find module bla bla bla" maybe you forgot some module to add to package.json
I added some pictures above
i dont see any error message where is the error then it looks like the error doesnt come from the build but it comes from your script itself because if error is from the build the last line that say "http:blablabla has deployed to heroku" is not gonna be there
Well it works perfectly fine when I see it on local host. Could it possibly be my package.json file?Added above.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.