我正在尝试为我的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
答案 0 :(得分:0)
好像mongodb-runner第一次从mongodb.org下载了一些文件,据this thread称,这些链接在某些版本中已更改。因此,请在运行mongodb-runner时先设置环境变量MONGODB_VERSION
,然后尝试不同的mongo版本:
MONGODB_VERSION=3.4.1 mongodb-runner