heroku diploy错误(远程拒绝)master-> master(预接收钩被拒绝)

时间:2019-05-30 12:26:52

标签: git express heroku branch package.json

(其他错误)

PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> heroku open
PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> heroku logs --tail
2019-05-31T16:45:02.171005+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:45:02.171116+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:45:02.171314+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:02.171426+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:45:02.171546+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:02.179317+00:00 app[web.1]:
2019-05-31T16:45:02.179463+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:02.179533+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_02_172Z-debug.log
2019-05-31T16:45:02.185867+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:02.186262+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:45:02.187262+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:45:02.187389+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:45:02.187579+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:02.187687+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:45:02.187797+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:02.193111+00:00 app[web.1]:
2019-05-31T16:45:02.193255+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:02.193337+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_02_188Z-debug.log
2019-05-31T16:45:02.258650+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:45:02.266584+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-31T16:45:02.249741+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:45:07.723357+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-31T16:45:09.873974+00:00 app[web.1]:
2019-05-31T16:45:09.874005+00:00 app[web.1]: > utube@1.0.0 prestart /app
2019-05-31T16:45:09.874008+00:00 app[web.1]: > npm run build
2019-05-31T16:45:09.874009+00:00 app[web.1]:
2019-05-31T16:45:10.385932+00:00 app[web.1]:
2019-05-31T16:45:10.385960+00:00 app[web.1]: > utube@1.0.0 prebuild /app
2019-05-31T16:45:10.385962+00:00 app[web.1]: > shx rm -rf build
2019-05-31T16:45:10.385964+00:00 app[web.1]:
2019-05-31T16:45:10.396373+00:00 app[web.1]: sh: 1: shx: not found
2019-05-31T16:45:10.403250+00:00 app[web.1]: npm ERR! file sh
2019-05-31T16:45:10.403532+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:10.403769+00:00 app[web.1]: npm ERR! errno ENOENT
2019-05-31T16:45:10.404003+00:00 app[web.1]: npm ERR! syscall spawn
2019-05-31T16:45:10.405101+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:45:10.405275+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:45:10.405526+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:10.405698+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:45:10.405864+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:10.413990+00:00 app[web.1]:
2019-05-31T16:45:10.414188+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:10.414314+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_10_407Z-debug.log
2019-05-31T16:45:10.442078+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:10.445480+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:45:10.451107+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:45:10.451370+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:45:10.451711+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:10.453601+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:45:10.456332+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:10.466855+00:00 app[web.1]:
2019-05-31T16:45:10.467160+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:10.467324+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_10_460Z-debug.log
2019-05-31T16:45:10.550003+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:45:10.537734+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:47:23.749632+00:00 app[api]: Set PORT, MONGO_URL_PROD, MONGO_URL, COOKIE_SECRET, AWS_KEY, AWS_PW config vars by user hbh4231@gmail.com
2019-05-31T16:47:23.749632+00:00 app[api]: Release v4 created by user hbh4231@gmail.com
2019-05-31T16:47:24.905228+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-31T16:47:29.835194+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-31T16:47:32.064545+00:00 app[web.1]:
2019-05-31T16:47:32.064571+00:00 app[web.1]: > utube@1.0.0 prestart /app
2019-05-31T16:47:32.064573+00:00 app[web.1]: > npm run build
2019-05-31T16:47:32.064575+00:00 app[web.1]:
2019-05-31T16:47:32.469293+00:00 app[web.1]:
2019-05-31T16:47:32.469338+00:00 app[web.1]: > utube@1.0.0 prebuild /app
2019-05-31T16:47:32.469341+00:00 app[web.1]: > shx rm -rf build
2019-05-31T16:47:32.469343+00:00 app[web.1]:
2019-05-31T16:47:32.475344+00:00 app[web.1]: sh: 1: shx: not found
2019-05-31T16:47:32.479177+00:00 app[web.1]: npm ERR! file sh
2019-05-31T16:47:32.479507+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:47:32.479713+00:00 app[web.1]: npm ERR! errno ENOENT
2019-05-31T16:47:32.479949+00:00 app[web.1]: npm ERR! syscall spawn
2019-05-31T16:47:32.481275+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:47:32.481386+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:47:32.481567+00:00 app[web.1]: npm ERR!
2019-05-31T16:47:32.481732+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:47:32.481842+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:47:32.490356+00:00 app[web.1]:
2019-05-31T16:47:32.490515+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:47:32.490598+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_47_32_483Z-debug.log
2019-05-31T16:47:32.497599+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:47:32.498150+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:47:32.499418+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:47:32.499643+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:47:32.499909+00:00 app[web.1]: npm ERR!
2019-05-31T16:47:32.500099+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:47:32.500279+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:47:32.507354+00:00 app[web.1]:
2019-05-31T16:47:32.507595+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:47:32.507739+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_47_32_501Z-debug.log
2019-05-31T16:47:32.574723+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:47:32.562071+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:47:54.648467+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=648f1dcd-fd24-4008-9316-9c5064c48981 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:47:55.002820+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=9e0aef22-1945-4863-843d-c9b06395c19c fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:03.197785+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=4498ed4d-0722-42bd-b3a9-a1cdccd2808e fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:03.601213+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=8e23955e-771d-42a1-a381-239137799a1e fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:04.440580+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=e33dde27-d710-45c8-ae47-88a211109e87 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:04.799842+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=2b7bde17-2418-44e4-baaf-8ceb38f61381 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:06.019477+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=5bf7c128-f282-4ceb-8f31-2aac4e3588ec fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:06.410926+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=88024c5c-027d-49e3-ba51-14b556f3a3fe fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https

我是初学者,想使用heroku部署Express应用程序,但是发生了错误。

首先,我输入推荐heroku create,它可以正常工作。但是接下来,当我输入git push heroku master时,发生了错误。我将添加我的package.json和错误日志。

错误点是`git push heroku master

这是package.json

{
  "name": "utube",
  "version": "1.0.0",
  "description": "clone youtube",
  "scripts": {
    "dev:server": "nodemon --exec babel-node src/init.js --delay 2 --ignore '.scss' --ignore 'static' ",
    "dev:assets": "cd src && cross-env WEBPACK_ENV=development webpack -w",
    "build:assets": "cd src && cross-env WEBPACK_ENV=production webpack",
    "build:server": "babel src --out-dir build",
    "copyAll": "xcopy .\\src\\static .\\build\\static\\ /s /y && xcopy .\\src\\views .\\build\\views\\ /s /y && xcopy .\\src\\uploads .\\build\\uploads",
    "build": "npm run build:assets && npm run build:server && npm run copyAll",
    "prebuild": "rd /s /q build",
    "tunnel": "ngrok http 4000",
    "start": "PRODUCTION=true node build/init.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/qudgus21/utube.git"
  },
  "author": "hwang",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/qudgus21/utube/issues"
  },
  "homepage": "https://github.com/qudgus21/utube#readme",
  "devDependencies": {
    "@babel/plugin-transform-runtime": "^7.4.4",
    "eslint": "^5.16.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-config-prettier": "^4.2.0",
    "eslint-plugin-import": "^2.17.2",
    "eslint-plugin-prettier": "^3.0.1",
    "nodemon": "^1.19.0",
    "prettier": "^1.17.0"
  },
  "dependencies": {
    "@babel/cli": "^7.4.4",
    "@babel/core": "^7.4.4",
    "@babel/node": "^7.4.5",
    "@babel/polyfill": "^7.4.4",
    "@babel/preset-env": "^7.4.4",
    "@babel/runtime": "^7.4.5",
    "autoprefixer": "^9.5.1",
    "aws-sdk": "^2.463.0",
    "axios": "^0.18.0",
    "babel-loader": "^8.0.5",
    "body-parser": "^1.19.0",
    "connect-mongo": "^2.0.3",
    "cookie-parser": "^1.4.4",
    "cross-env": "^5.2.0",
    "css-loader": "^2.1.1",
    "dotenv": "^8.0.0",
    "express": "^4.16.4",
    "express-flash": "0.0.2",
    "express-session": "^1.16.1",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "flash": "^1.1.0",
    "helmet": "^3.18.0",
    "mongoose": "^5.5.6",
    "morgan": "^1.9.1",
    "multer": "^1.4.1",
    "multer-s3": "^2.9.0",
    "node-sass": "^4.12.0",
    "passport": "^0.4.0",
    "passport-github": "^1.1.0",
    "passport-local": "^1.0.0",
    "passport-local-mongoose": "^5.0.1",
    "postcss-loader": "^3.0.0",
    "pug": "^2.0.3",
    "sass-loader": "^7.1.0",
    "webpack": "^4.30.0",
    "webpack-cli": "^3.3.2"
  },
  "engines": {
    "node": "10.15.3",
    "npm": "6.4.1"
  }
}

这是错误

PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> git push heroku master
Enumerating objects: 87, done.
Counting objects: 100% (87/87), done.
Delta compression using up to 8 threads
Compressing objects: 100% (81/81), done.
Writing objects: 100% (87/87), 152.95 KiB | 3.00 MiB/s, done.
Total 87 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  10.15.3
remote:        engines.npm (package.json):   6.4.1
remote:
remote:        Resolving node version 10.15.3...
remote:        Downloading and installing node 10.15.3...
remote:        npm 6.4.1 already installed with node
remote:
remote: -----> Installing dependencies
remote:        Installing node modules (package.json + package-lock)
remote:
remote:        > node-sass@4.12.0 install /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass
remote:        > node scripts/install.js
remote:
remote:        Downloading binary from https://github.com/sass/node-sass/releases/download/v4.12.0/linux-x64-64_binding.node
remote:        Download complete
remote:        Binary saved to /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote:        Caching binary to /tmp/npmcache.Ulx4H/node-sass/4.12.0/linux-x64-64_binding.node
remote:
remote:        > core-js@3.1.3 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/@babel/register/node_modules/core-js
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > core-js@2.6.9 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/core-js
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > core-js-pure@3.1.3 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/core-js-pure
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > node-sass@4.12.0 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass
remote:        > node scripts/build.js
remote:
remote:        Binary found at /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote:        Testing binary
remote:        Binary is fine
remote:
remote:        > nodemon@1.19.1 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/nodemon
remote:        > node bin/postinstall || exit 0
remote:
remote:        Love nodemon? You can now support the project via the open collective:
remote:         > https://opencollective.com/nodemon/donate
remote:
remote:
remote:        > webpack-cli@3.3.2 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/webpack-cli
remote:        > node ./bin/opencollective.js
remote:
remote:
remote:
remote:                                    Thanks for using Webpack!
remote:                         Please consider donating to our Open Collective
remote:                                to help us maintain this package.
remote:
remote:
remote:
remote:                         Donate: https://opencollective.com/webpack/donate
remote:
remote:
remote:        added 1057 packages from 584 contributors and audited 12558 packages in 26.182s
remote:        found 0 vulnerabilities
remote:
remote:
remote: -----> Build
remote:        Running build
remote:
remote:        > utube@1.0.0 prebuild /tmp/build_7084f666a522aa57ba16b83206ec0b94
remote:        > rd /s /q build
remote:
remote: sh: 1: rd: not found
remote: npm ERR! file sh
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno ENOENT
remote: npm ERR! syscall spawn
remote: npm ERR! utube@1.0.0 prebuild: `rd /s /q build`
remote: npm ERR! spawn ENOENT
remote: npm ERR!
remote: npm ERR! Failed at the utube@1.0.0 prebuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.Ulx4H/_logs/2019-05-30T11_43_28_551Z-debug.log
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 protected-depths-46400.
remote:
To https://git.heroku.com/protected-depths-46400.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/protected-depths-46400.git'

emphasized text

几天来我一直在寻找解决方案,但我不知道。 请帮助我。我会等你的回答。

1 个答案:

答案 0 :(得分:1)

您有一个在Heroku上无法使用的预构建脚本:

"prebuild": "rd /s /q build",

rd是Windows命令,但是Heroku不能运行Windows。这反映在您的错误消息中:

sh: 1: rd: not found

您似乎正在尝试在构建之前删除build目录。但是我认为这不是必需的。当然在Heroku上不需要,因为每个构建都在干净的环境中完成。尝试将其取出。

编辑:您对xcopy的问题是相同的:这是Windows命令。

由于您实际上需要执行此步骤,因此请考虑使用类似shx之类的内容,以便您可以跨平台方式重写该脚本。我暂时没有Windows机器,但是类似

"devDependencies": {
  "shx": "^0.3.2",
},

"scripts": {
  "copyAll": "shx cp -r src/static build/static && shx cp -r src/views build/views && shx cp -r src/uploads build/uploads",
},

应该工作。

如果事实证明您确实需要执行prebuild步骤,那么您也应该可以在其中使用shx,例如

"prebuild": "shx rm -r build"