簡體   English   中英

很難將我的 MERN 堆棧應用程序部署到 Heroku

[英]Having a HARD time deploying my MERN stack app to Heroku

我一直在關注 brad traversy 的托管全棧 mern 應用程序的指南,

但是在我運行 git push heroku master 之后,我不斷收到此錯誤:

$ git push heroku master
Enumerating objects: 39, done.
Counting objects: 100% (39/39), done.
Delta compression using up to 8 threads
Compressing objects: 100% (36/36), done.
Writing objects: 100% (39/39), 427.21 KiB | 8.06 MiB/s, done.
Total 39 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 12.x...
remote:        Downloading and installing node 12.20.1...
remote:        Using default npm version: 6.14.10
remote:
remote: -----> Installing dependencies
remote:        Installing node modules
remote:
remote:        > nodemon@2.0.6 postinstall /tmp/build_a03a558d/node_modules/node
mon
remote:        > node bin/postinstall || exit 0
remote:
remote:        Love nodemon? You can now support the project via the open collec
tive:
remote:         > https://opencollective.com/nodemon/donate
remote:
remote:        added 296 packages in 4.302s
remote:
remote: -----> Build
remote:        Detected both "build" and "heroku-postbuild" scripts
remote:        Running heroku-postbuild
remote:
remote:        > server@1.0.0 heroku-postbuild /tmp/build_a03a558d
remote:        > NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && np
m run build --prefix frontend
remote:
remote:        up to date in 0.241s
remote:        found 0 vulnerabilities
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_a03a558d/frontend/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_a03a
558d/frontend/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.ZT0se/_logs/2021-01-26T16_52_50_692Z-debug.lo
g
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! server@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm
 install --prefix frontend && npm run build --prefix frontend`
remote: npm ERR! Exit status 254
remote: npm ERR!
remote: npm ERR! Failed at the server@1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additi
onal logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.ZT0se/_logs/2021-01-26T16_52_50_713Z-debug.lo
g
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common is
sues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploy
s
remote:
remote:        Some possible problems:
remote:
remote:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying
-a-node-js-version
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 fathomless-thicket-55387.
remote:
To https://git.heroku.com/fathomless-thicket-55387.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fathomless-thicket-55
387.git'

我不知道為什么會收到這些錯誤消息...遠程:npm ERR。 路徑 /tmp/build_a03a558d/frontend/package:json 遠程:npm ERR:errno -2 遠程,npm ERR。 enoent ENOENT:沒有這樣的文件或目錄,打開'/tmp/build_a03a 558d/frontend/package.json'

你需要檢查

  1. frontend文件夾中是否有package.json文件。 您可以在 git 中查看它是否存在。 可能會在 gitignore 中提到。

  2. Whether your heroku-postbuild runs from package.json (not the same package.json file you have in frontend folder) which is on the same level with folder frontend . 像這樣:

    • package.json
    • /前端

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM