![](/img/trans.png)
[英]My node.js Server is running successfully in heroku but build failed.( Timeout running buildpack)
[英]heroku build failed. “mongoUrl”://“mongodb…” syntax error and more
我必須承認,我是編程的初學者。 我正在做一個在線課程,我想使用 heroku 和 mongodb 連接 api。 我想我按照說明遇到了一些問題,因為視頻比 heroku 和 mongodb 的當前 state 舊。 我設法git push heroku master
,但是當我到達 heroku 並啟動應用程序時,它說發生了錯誤。 然后我跑了heroku logs --tail
,我檢查了我的構建,這表明
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 8.10.0
engines.npm (package.json): unspecified (use default)
Resolving node version 8.10.0...
Downloading and installing node 8.10.0...
Using default npm version: 5.6.0
-----> Installing dependencies
Installing node modules (package.json)
> uws@9.14.0 install /tmp/build_63fff292b65e6a987cf3dc9195527d57/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0
> core-js@2.6.10 postinstall /tmp/build_63fff292b65e6a987cf3dc9195527d57/node_modules/core-js
> node postinstall || echo "ignore"
added 608 packages in 32.816s
-----> Build
Running build
> slacky-slack@1.0.0 build /tmp/build_63fff292b65e6a987cf3dc9195527d57
> babel src -s -D -d dist --presets es2015,stage-0
SyntaxError: src/config/index.js: Unexpected token, expected , (7:21)
5 | // "mongoUrl": "mongodb://localhost:27017/chat-api",
6 | "port": process.env.PORT,
> 7 | "mongoUrl": mongodb://esteP:<CEpalacios2019>@chattychatchat-shard-00-00-6ydjb.mongodb.net:27017,chattychatchat-shard-00-01-6ydjb.mongodb.net:27017,chattychatchat-shard-00-02-6ydjb.mongodb.net:27017/test?ssl=true&replicaSet=chattychatchat-shard-0&authSource=admin&retryWrites=true&m=majority ,
| ^
8 | "bodyLimit": "100kb"
9 | }
10 |
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! slacky-slack@1.0.0 build: `babel src -s -D -d dist --presets es2015,stage-0`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the slacky-slack@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.5odQG/_logs/2019-10-19T12_28_48_165Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
僅供參考,這個 index.js 文件看起來像this import mongodb from 'mongodb'; export default { // "port": 3005, // "mongoUrl": "mongodb://localhost:27017/chat-api", "port": process.env.PORT, "mongoUrl": "mongodb://esteP:<**********>@chattychatchat-shard-00-00-6ydjb.mongodb.net:27017,chattychatchat-shard-00-01-6ydjb.mongodb.net:27017,chattychatchat-shard-00-02-6ydjb.mongodb.net:27017/test?ssl=true&replicaSet=chattychatchat-shard-0&authSource=admin&retryWrites=true&w=majority", "bodyLimit": "100kb" }
this import mongodb from 'mongodb'; export default { // "port": 3005, // "mongoUrl": "mongodb://localhost:27017/chat-api", "port": process.env.PORT, "mongoUrl": "mongodb://esteP:<**********>@chattychatchat-shard-00-00-6ydjb.mongodb.net:27017,chattychatchat-shard-00-01-6ydjb.mongodb.net:27017,chattychatchat-shard-00-02-6ydjb.mongodb.net:27017/test?ssl=true&replicaSet=chattychatchat-shard-0&authSource=admin&retryWrites=true&w=majority", "bodyLimit": "100kb" }
除了語法錯誤,我不明白大多數這些錯誤,但我不知道問題出在哪里。 感謝您為這個菜鳥提供的所有幫助:)
嘗試編輯src/config/index.js
並更改:
"mongoUrl": mongodb://esteP:<CEpalacios2019>@chattychatchat-shard-00-00-6ydjb.mongodb.net:27017,chattychatchat-shard-00-01-6ydjb.mongodb.net:27017,chattychatchat-shard-00-02-6ydjb.mongodb.net:27017/test?ssl=true&replicaSet=chattychatchat-shard-0&authSource=admin&retryWrites=true&m=majority
對此:
"mongoUrl": "mongodb://esteP:<CEpalacios2019>@chattychatchat-shard-00-00-6ydjb.mongodb.net:27017,chattychatchat-shard-00-01-6ydjb.mongodb.net:27017,chattychatchat-shard-00-02-6ydjb.mongodb.net:27017/test?ssl=true&replicaSet=chattychatchat-shard-0&authSource=admin&retryWrites=true&m=majority"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.