1

I am new to the usage of git, and having trouble pushing.

I have a Heroku app that I'm practicing on. I have installed the Heroku CLI, and this is what I'm trying to do:

heroku login //successful
heroku git:clone -a myapp //successful, but with warning that I have cloned an empty repository. As I understand, this is normal?
Then, I'm creating a readme.txt file in the folder. Should this be in the /myappfolder, or in the /myapp/.gitfolder?

When I do git add readme.txt in the myapp folder the terminal does not give any errors og success messages

Then I do git commit -am "add readme" //Seems successful

Then I do git push heroku master // Fails

The error I'm getting when I push:

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 471 bytes | 471.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz
remote:        
remote:  !     ERROR: Application not supported by 'heroku/nodejs' buildpack
remote:  !     
remote:  !     The 'heroku/nodejs' buildpack is set on this application, but wa
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:  !     readme.txt
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
remote: 
remote: 
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to myapp.
remote: 
To https://git.heroku.com/myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myapp.git'    

Where is this going wrong?

EDIT

package.json

{
  "name": "myapp",
  "version": "1.0.0",
  "description": "lamwork",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "example",
    "heroku"
  ],
  "author": "My Name",
  "license": "ISC"
}, 
 "engines": {
    "node": "10.15.0"
  }
}   

After committing the package.json I get this error when trying to push:

Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (8/8), 1.03 KiB | 528.00 KiB/s, done.
Total 8 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote: parse error: Expected value before ',' at line 15, column 2
remote:  !     Unable to parse package.json
remote: 
remote: 
remote: -----> Change to Node.js build process 
remote:        Heroku has begun executing the "build" script defined in package.json
remote:        during Node.js builds.
remote: 
remote:        Read more: https://devcenter.heroku.com/changelog-items/1573
remote: 
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:        
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:        
remote:        Love,
remote:        Heroku
remote:        
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !   Push rejected to myapp.
remote: 
To https://git.heroku.com/myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myapp.git'
Eccles
  • 394
  • 1
  • 3
  • 13
  • Possible duplicate of [git, Heroku: pre-receive hook declined](https://stackoverflow.com/questions/8216586/git-heroku-pre-receive-hook-declined) – Pau Mar 12 '19 at 08:52
  • you're trying to push a not supported nodejs app to heroku. They're basically preventing this using a pre-received hook and for instance checking if it is ok or not > https://stackoverflow.com/questions/8216586/git-heroku-pre-receive-hook-declined – Pau Mar 12 '19 at 08:54
  • 1
    Your codebase is missing a package.json and heroku thinks that it's not a nodejs app. – evolutionxbox Mar 12 '19 at 09:48
  • @evolutionxbox I have added package.json now. But still getting error. Please see edited question where I have added my package.json – Eccles Mar 12 '19 at 10:25

1 Answers1

2

Then, I'm creating a readme.txt file in the folder. Should this be in the /myapp folder, or in the /myapp/.git folder?

The former, /myapp. /myapp/.git is used by Git for saving its contents.

remote: parse error: Expected value before ',' at line 15, column 2

And your package.json is containing error at that line. You have mis-added a } to terminate the JSON object. Fix it and repush again.

Geno Chen
  • 4,916
  • 6
  • 21
  • 39