简体   繁体   中英

heroku build failed. “mongoUrl”://“mongodb…” syntax error and more

I must admit, I'm quite a beginner in programming. I'm doing an online course where I want to connect an api using heroku and mongodb. I think I've got some problems following the instructions because the video is older than the current state of heroku and mongodb. I managed to git push heroku master but when I got to heroku and start the app it says an error occured. Then I ran heroku logs --tail , I checked my build and this showed

-----> 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

FYI this index.js file looks like 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" }

I don't understand most of these errors, except for the syntax error, but I don't know where is the problem. Thanks for all the help you can give to this noob:)

Try to edit src/config/index.js and change this:

"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

to this:

"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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM