我必须承认,我是编程方面的初学者。
我正在在线课程中学习如何使用heroku和mongodb连接api。我认为按照说明进行操作会遇到一些问题,因为该视频比heroku和mongodb的当前状态还旧。
我设法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" }
除了语法错误外,我不了解其中大多数错误,但我不知道问题出在哪里。 感谢您为这个菜鸟提供的所有帮助:)
答案 0 :(得分:0)
尝试编辑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"