gpt4 book ai didi

node.js - 解析服务器和 mongodb 问题

转载 作者:可可西里 更新时间:2023-11-01 10:45:36 28 4
gpt4 key购买 nike

我正在尝试为我的 Express 应用程序设置解析服务器的本地安装。这是我所做的:

npm install -g parse-server mongodb-runner

然后:

mongodb-runner start

触发了这个错误:

  Starting a MongoDB deployment to test against...{ HTTPError: Response code 403 (Forbidden)
at EventEmitter.ee.on.res (/usr/local/lib/node_modules/mongodb-runner/node_modules/got/index.js:250:24)
at EventEmitter.emit (events.js:182:13)
at Immediate.setImmediate (/usr/local/lib/node_modules/mongodb-runner/node_modules/got/index.js:99:8)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
name: 'HTTPError',
host: 'fastdl.mongodb.org',
hostname: 'fastdl.mongodb.org',
method: 'GET',
path: '/osx/mongodb-macos-x86_64-4.0.3.tgz',
protocol: 'https:',
url:
'https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.0.3.tgz',
statusCode: 403,
statusMessage: 'Forbidden',
headers:
{ 'content-type': 'application/xml',
'transfer-encoding': 'chunked',
connection: 'close',
date: 'Wed, 17 Oct 2018 18:38:43 GMT',
server: 'AmazonS3',
'x-cache': 'Error from cloudfront',
via:
'1.1 c743f1ce1ce65e454843328ae4e050a2.cloudfront.net (CloudFront)',
'x-amz-cf-id': 'eA7O6955PJVLdcvfXCAuTW3YOEGRoGcWGxGXRgAiPq8zbGFyBvug8Q==' } }

因此,我决定在 mongodb.com 上创建一个集群,而不是在本地运行 mongodb。然后我尝试运行这个连接到集群的命令(当然我用正确的值替换了 APP_ID、MASTER_KEY 和 MONGODB_DATABASE_URI):

parse-server --appId APP_ID --masterKey MASTER_KEY --databaseURI MONGODB_DATABASE_URI

这是我得到的错误:

/usr/local/lib/node_modules/parse-server/lib/ParseServer.js:225
throw err;
^

TypeError: Cannot read property 'close' of undefined
at topology.connect (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/lib/operations/mongo_client_ops.js:412:16)
at ReplSet.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/lib/topologies/replset.js:364:11)
at Object.onceWrapper (events.js:273:13)
at ReplSet.emit (events.js:182:13)
at ReplSet.EventEmitter.emit (domain.js:442:20)
at /usr/local/lib/node_modules/parse-server/node_modules/mongodb-core/lib/topologies/replset.js:631:23
at Server.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb-core/lib/topologies/replset.js:357:9)
at Object.onceWrapper (events.js:273:13)
at Server.emit (events.js:182:13)
at Server.EventEmitter.emit (domain.js:442:20)

我已经在谷歌上搜索了很长时间,但我无法弄清楚。 parse-server 和 mongodb 都是最新的。说 parse-server 是 3.0.0 和 mongodb 是 3.1.8

最佳答案

看起来 mongodb-runner 第一次从 mongodb.org 下载了一些文件,根据 this thread ,对于某些版本,这些链接已更改。因此,在运行 mongodb-runner 时通过设置环境变量 MONGODB_VERSION 来尝试不同的 mongo 版本:

MONGODB_VERSION=3.4.1 mongodb-runner

关于node.js - 解析服务器和 mongodb 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52861652/

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