gpt4 book ai didi

node.js - 由于 MongoDB,Heroku 中的应用程序错误?

转载 作者:行者123 更新时间:2023-12-02 16:03:37 27 4
gpt4 key购买 nike

我正在尝试将项目部署到heroku。项目可以在本地运行,已成功构建:

Ties-MBP:devconnector chengtie$ git push heroku master
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 708 bytes | 708.00 KiB/s, done.
Total 7 (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): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 12.x...
remote: Downloading and installing node 12.14.1...
remote: Using default npm version: 6.13.4
remote:
remote: -----> Restoring cache
remote: - node_modules
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote: audited 526 packages in 2.51s
remote:
remote: 4 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 0 vulnerabilities
remote:
remote:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > devconnector@1.0.0 heroku-postbuild /tmp/build_2d10cdda70895c0ca15ac9e91acad1a9
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote:
remote: > core-js@2.6.11 postinstall /tmp/build_2d10cdda70895c0ca15ac9e91acad1a9/client/node_modules/babel-runtime/node_modules/core-js
remote: > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote:
remote: > core-js@3.6.4 postinstall /tmp/build_2d10cdda70895c0ca15ac9e91acad1a9/client/node_modules/core-js
remote: > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote:
remote: > core-js-pure@3.6.4 postinstall /tmp/build_2d10cdda70895c0ca15ac9e91acad1a9/client/node_modules/core-js-pure
remote: > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote: added 1672 packages from 796 contributors and audited 906305 packages in 41.702s
remote:
remote: 33 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 0 vulnerabilities
remote:
remote:
remote: > client@0.1.0 build /tmp/build_2d10cdda70895c0ca15ac9e91acad1a9/client
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Compiled with warnings.
remote:
remote: ./src/components/profile/ProfileGithub.js
remote: Line 10:6: React Hook useEffect has a missing dependency: 'username'. Either include it or remove the dependency array react-hooks/exhaustive-deps
remote:
remote: ./src/components/post/Post.js
remote: Line 14:6: React Hook useEffect has a missing dependency: 'match.params.id'. Either include it or remove the dependency array react-hooks/exhaustive-deps
remote:
remote: ./src/actions/post.js
remote: Line 158:11: 'res' is assigned a value but never used no-unused-vars
remote:
remote: ./src/components/profiles/ProfileItem.js
remote: Line 1:17: 'Fragment' is defined but never used no-unused-vars
remote: Line 1:27: 'useEffect' is defined but never used no-unused-vars
remote: Line 4:10: 'connect' is defined but never used no-unused-vars
remote: Line 5:8: 'Spinner' is defined but never used no-unused-vars
remote: Line 6:10: 'getProfiles' is defined but never used no-unused-vars
remote:
remote: ./src/components/profile/Profile.js
remote: Line 21:6: React Hook useEffect has a missing dependency: 'match.params.id'. Either include it or remove the dependency array react-hooks/exhaustive-deps
remote:
remote: ./src/actions/alert.js
remote: Line 4:10: 'STATES' is defined but never used no-unused-vars
remote:
remote: ./src/store.js
remote: Line 5:8: 'App' is defined but never used no-unused-vars
remote:
remote: ./src/components/profile-forms/EditProfile.js
remote: Line 71:6: React Hook useEffect has missing dependencies: 'profile.bio', 'profile.company', 'profile.githubusername', 'profile.location', 'profile.skills', 'profile.social', 'profile.status', and 'profile.website'. Either include them or remove the dependency array. If 'setFormData' needs the current value of 'profile.company', you can also switch to useReducer instead of useState and read 'profile.company' in the reducer react-hooks/exhaustive-deps
remote:
remote: Search for the keywords to learn more about each warning.
remote: To ignore, add // eslint-disable-next-line to the line before.
remote:
remote: File sizes after gzip:
remote:
remote: 193.04 KB build/static/js/2.6988f640.chunk.js
remote: 18.01 KB build/static/js/main.7cad9bf2.chunk.js
remote: 1.83 KB build/static/css/main.11b62bc3.chunk.css
remote: 772 B build/static/js/runtime-main.cea588d5.js
remote:
remote: The project was built assuming it is hosted at the server root.
remote: You can control this with the homepage field in your package.json.
remote: For example, add this to build it for GitHub Pages:
remote:
remote: "homepage" : "http://myname.github.io/myapp",
remote:
remote: The build folder is ready to be deployed.
remote: You may serve it with a static server:
remote:
remote: yarn global add serve
remote: serve -s build
remote:
remote: Find out more about deployment here:
remote:
remote: bit.ly/CRA-deploy
remote:
remote:
remote: -----> Caching build
remote: - node_modules
remote:
remote: -----> Pruning devDependencies
remote: removed 125 packages and audited 309 packages in 3.58s
remote:
remote: 1 package is looking for funding
remote: run `npm fund` for details
remote:
remote: found 0 vulnerabilities
remote:
remote:
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for buildpack -> web
remote:
remote: -----> Compressing...
remote: Done: 65M
remote: -----> Launching...
remote: Released v4
remote: https://ancient-shelf-71404.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/ancient-shelf-71404.git
e0ea014..b56f9ce master -> master

但是,https://ancient-shelf-71404.herokuapp.com/ 显示错误。

enter image description here

这是heroku log --tail的结果:

2020-01-29T09:50:20.000000+00:00 app[api]: Build started by user chengtie@gmail.com
2020-01-29T09:52:30.353917+00:00 app[api]: Deploy e0ea014a by user chengtie@gmail.com
2020-01-29T09:52:30.368629+00:00 app[api]: Scaled to web@1:Free by user chengtie@gmail.com
2020-01-29T09:52:30.353917+00:00 app[api]: Release v3 created by user chengtie@gmail.com
2020-01-29T09:52:32.000000+00:00 app[api]: Build succeeded
2020-01-29T09:52:39.870533+00:00 heroku[web.1]: Starting process with command `npm start`
2020-01-29T09:52:42.529914+00:00 app[web.1]:
2020-01-29T09:52:42.529947+00:00 app[web.1]: > devconnector@1.0.0 start /app
2020-01-29T09:52:42.529949+00:00 app[web.1]: > node server
2020-01-29T09:52:42.529951+00:00 app[web.1]:
2020-01-29T09:52:43.030242+00:00 app[web.1]: the options [userFindAndModify] is not supported
2020-01-29T09:52:43.135493+00:00 app[web.1]: express-validator: requires to express-validator/check are deprecated.You should just use require("express-validator") instead.
2020-01-29T09:52:43.304468+00:00 app[web.1]: Server started on port 24212
2020-01-29T09:52:43.339505+00:00 app[web.1]: (node:23) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-01-29T09:52:43.736912+00:00 heroku[web.1]: State changed from starting to up
2020-01-29T09:52:44.728064+00:00 app[web.1]: failed to connect to server [cluster0-shard-00-01-jnhgq.azure.mongodb.net:27017] on first connect [MongoNetworkError: connection 4 to cluster0-shard-00-01-jnhgq.azure.mongodb.net:27017 closed
2020-01-29T09:52:44.728074+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connection.js:372:9)
2020-01-29T09:52:44.728077+00:00 app[web.1]: at Object.onceWrapper (events.js:313:26)
2020-01-29T09:52:44.728079+00:00 app[web.1]: at TLSSocket.emit (events.js:223:5)
2020-01-29T09:52:44.728081+00:00 app[web.1]: at net.js:664:12
2020-01-29T09:52:44.728083+00:00 app[web.1]: at TCP.done (_tls_wrap.js:481:7) {
2020-01-29T09:52:44.728085+00:00 app[web.1]: name: 'MongoNetworkError',
2020-01-29T09:52:44.728087+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-01-29T09:52:44.728089+00:00 app[web.1]: }]
2020-01-29T09:52:44.745668+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-01-29T09:52:44.746170+00:00 app[web.1]: npm ERR! errno 1
2020-01-29T09:52:44.748403+00:00 app[web.1]: npm ERR! devconnector@1.0.0 start: `node server`
2020-01-29T09:52:44.748626+00:00 app[web.1]: npm ERR! Exit status 1
2020-01-29T09:52:44.748985+00:00 app[web.1]: npm ERR!
2020-01-29T09:52:44.749178+00:00 app[web.1]: npm ERR! Failed at the devconnector@1.0.0 start script.
2020-01-29T09:52:44.749370+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-01-29T09:52:44.763478+00:00 app[web.1]:
2020-01-29T09:52:44.763782+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-01-29T09:52:44.763957+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-01-29T09_52_44_751Z-debug.log
2020-01-29T09:52:44.900668+00:00 heroku[web.1]: State changed from up to crashed
2020-01-29T09:52:44.904360+00:00 heroku[web.1]: State changed from crashed to starting
2020-01-29T09:52:44.883640+00:00 heroku[web.1]: Process exited with status 1
2020-01-29T09:52:55.677596+00:00 heroku[web.1]: Starting process with command `npm start`
2020-01-29T09:52:58.421225+00:00 app[web.1]:
2020-01-29T09:52:58.421243+00:00 app[web.1]: > devconnector@1.0.0 start /app
2020-01-29T09:52:58.421244+00:00 app[web.1]: > node server
2020-01-29T09:52:58.421246+00:00 app[web.1]:
2020-01-29T09:52:59.055220+00:00 app[web.1]: the options [userFindAndModify] is not supported
2020-01-29T09:52:59.216486+00:00 app[web.1]: express-validator: requires to express-validator/check are deprecated.You should just use require("express-validator") instead.
2020-01-29T09:52:59.465530+00:00 app[web.1]: Server started on port 49717
2020-01-29T09:52:59.501991+00:00 app[web.1]: (node:23) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-01-29T09:53:00.046649+00:00 heroku[web.1]: State changed from starting to up
2020-01-29T09:53:00.938222+00:00 app[web.1]: failed to connect to server [cluster0-shard-00-01-jnhgq.azure.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to cluster0-shard-00-01-jnhgq.azure.mongodb.net:27017 closed
2020-01-29T09:53:00.938255+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connection.js:372:9)
2020-01-29T09:53:00.938259+00:00 app[web.1]: at Object.onceWrapper (events.js:313:26)
2020-01-29T09:53:00.938261+00:00 app[web.1]: at TLSSocket.emit (events.js:223:5)
2020-01-29T09:53:00.938263+00:00 app[web.1]: at net.js:664:12
2020-01-29T09:53:00.938266+00:00 app[web.1]: at TCP.done (_tls_wrap.js:481:7) {
2020-01-29T09:53:00.938268+00:00 app[web.1]: name: 'MongoNetworkError',
2020-01-29T09:53:00.938270+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-01-29T09:53:00.938273+00:00 app[web.1]: }]
2020-01-29T09:53:00.954724+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-01-29T09:53:00.955173+00:00 app[web.1]: npm ERR! errno 1
2020-01-29T09:53:00.956874+00:00 app[web.1]: npm ERR! devconnector@1.0.0 start: `node server`
2020-01-29T09:53:00.957133+00:00 app[web.1]: npm ERR! Exit status 1
2020-01-29T09:53:00.957403+00:00 app[web.1]: npm ERR!
2020-01-29T09:53:00.957668+00:00 app[web.1]: npm ERR! Failed at the devconnector@1.0.0 start script.
2020-01-29T09:53:00.957894+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-01-29T09:53:00.967799+00:00 app[web.1]:
2020-01-29T09:53:00.968049+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-01-29T09:53:00.968243+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-01-29T09_53_00_959Z-debug.log
2020-01-29T09:53:01.058482+00:00 heroku[web.1]: State changed from up to crashed
2020-01-29T09:53:01.041360+00:00 heroku[web.1]: Process exited with status 1
2020-01-29T09:53:01.411353+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ancient-shelf-71404.herokuapp.com request_id=cda60434-e53d-4f35-a3c7-778f7a9481a3 fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:53:02.219416+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ancient-shelf-71404.herokuapp.com request_id=098c8b5f-7c75-4330-b5b3-4b4295598787 fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:53:46.942378+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/%20deployed%20to%20Heroku" host=ancient-shelf-71404.herokuapp.com request_id=4ec43208-89e8-4db5-8391-33b99a490866 fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:53:47.393982+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ancient-shelf-71404.herokuapp.com request_id=4653c947-764c-47ea-9653-5ae5b8813a29 fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:55:50.234324+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ancient-shelf-71404.herokuapp.com request_id=c58225cf-585c-4290-906f-54820900eee4 fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:55:50.686349+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ancient-shelf-71404.herokuapp.com request_id=a1fce16b-9952-4489-8a79-72b5a1855d7a fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:58:24.907640+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ancient-shelf-71404.herokuapp.com request_id=0d0ca80c-ea3a-4c8d-b930-8ea7f69fa64b fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:58:25.349389+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ancient-shelf-71404.herokuapp.com request_id=aad9749e-a961-4a49-a4f7-3aff58aada4a fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:58:54.771239+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ancient-shelf-71404.herokuapp.com request_id=4302a52d-553a-4be5-ac4d-b2acb61cce93 fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https
2020-01-29T09:58:55.211610+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ancient-shelf-71404.herokuapp.com request_id=eb5f47a0-0b37-44f1-93cc-4b3b630ecc07 fwd="176.144.215.193" dyno= connect= service= status=503 bytes= protocol=https

我使用 MongoDB Atlas。这是生产.json:

{
"mongoURI": "mongodb+srv://cheng123:...@cluster0-jnhgq.azure.mongodb.net/test?retryWrites=true&w=majority",
"jwtSecret": "mysecrettoken",
"githubClientId": ...,
"githubSecret": ...
}

有人知道这是怎么回事吗?

最佳答案

听起来您被防火墙阻止了。

MongoDb Atlas 建议将 IP 白名单作为其安全功能之一 - 您可以在门户的集群安全设置下查看是否已设置此功能。如果已设置(并且不使用 0.0.0.0 通配符),那么您需要将服务器 IP 范围添加到白名单中。请参阅https://docs.atlas.mongodb.com/security-whitelist/

*Disclaimer - I dont work with Heroku, so I'm not sure whether you need to open the 27017 port for your application as well. This article may be useful if your Heroku instance has dynamic IPs - https://www.mongodb.com/blog/post/integrating-mongodb-atlas-with-heroku-private-spaces

关于node.js - 由于 MongoDB,Heroku 中的应用程序错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59964685/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com