我对git的使用并不陌生,并且在推送方面遇到麻烦。
我有一个正在练习的Heroku应用程序。我已经安装了Heroku CLI,这就是我想要做的:
heroku login
//成功
heroku git:clone -a myapp
//成功,但是警告我已经克隆了一个空的存储库。据我了解,这很正常吗?
然后,我在文件夹中创建一个readme.txt
文件。应该在/myapp
文件夹中还是在/myapp/.git
文件夹中?
当我在git add readme.txt
文件夹中进行myapp
时,终端不会显示任何错误或成功消息
然后我做git commit -am "add readme"
//似乎成功
然后我做git push heroku master
//失败
推送时出现的错误:
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'
这出了什么问题?
编辑
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"
}
}
提交package.json后,我在尝试推送时收到此错误:
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'
答案 0 :(得分:2)
然后,我在文件夹中创建一个readme.txt文件。应该在
/myapp
文件夹中还是/myapp/.git
文件夹中?
前者/myapp
。 /myapp/.git
由Git用于保存其内容。
远程:解析错误:在第15行第2列的','之前的期望值
您的package.json
在该行包含错误。您误加了}
以终止JSON对象。修复它,然后再次重推。