1

我正在尝试在 Windows 上运行流星应用程序。我在我的机器上运行了本地 mongodb,我还在<b>MONGO_URL=mongodb://127.0.0.1:27017/sample</b>我的系统上设置了环境变量。仍然流星应用程序无法连接到它。可能是什么问题。

以下是错误:-

C:\workspace\node-workspace\gm>meteor
[[[[[ C:\workspace\node-workspace\gm ]]]]]

=> `Meteor server running on: <b>http://127.0.0.1:3000/</b>`

app/packages/mongo-livedata/mongo_driver.js:113
      throw err;
            ^
Error: failed to connect to [127.0.0.1:3002]
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
    at EventEmitter.emit (events.js:126:20)
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
    at EventEmitter.emit (events.js:99:17)
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Meteor server restarted

app/packages/mongo-livedata/mongo_driver.js:113
      throw err;
            ^
Error: failed to connect to [127.0.0.1:3002]
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
    at EventEmitter.emit (events.js:126:20)
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
    at EventEmitter.emit (events.js:99:17)
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Meteor server restarted

app/packages/mongo-livedata/mongo_driver.js:113
      throw err;
            ^
Error: failed to connect to [127.0.0.1:3002]
    at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
    at EventEmitter.emit (events.js:126:20)
    at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
    at EventEmitter.emit (events.js:99:17)
    at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
4

3 回答 3

2

鉴于堆栈跟踪表明流星仍在尝试连接到端口 3002 上的 mongoDb 实例,那么要么您没有正确设置环境变量,要么您没有重新加载 cmd shell 以获得新值。

你是如何设置MONGO_URL 的?如果您通过系统属性设置它或更新了 autoexec.bat,那么您需要重新加载 cmd shell。

您可以通过在 cmd shell 中键入来查看当前值:

echo %MONGO_URL%

然后为当前环境设置它,你可以这样做:

set MONGO_URL=mongodb://127.0.0.1:27017/sample
于 2013-05-27T16:20:17.473 回答
1

我知道已经有一段时间了,但我遇到了同样的问题(在 7 月 13 日),我没有时间弄清楚,最后安装了一个运行良好的 Linux。

但是最近我有时间回过头来。以下是谷歌群组中关于此事的一些讨论 - https://groups.google.com/forum/#!topic/meteor-talk/AE6GYrJImAo

我发现 Mongo DB 进程甚至没有启动,mongo_runner.js 内部有些冲突......我的解决方案是手动启动 mongo

C:\Program Files (x86)\Meteor\mongodb\bin>mongod -port 3002 --dbpath C:\Users\username\project\.meteor\local\db

上面在所需端口上启动项目并为您的项目指定数据库文件夹......之后就像往常一样启动meteor。

于 2014-01-10T14:37:24.023 回答
0

从 0.7.1 版开始,meteor mongodb 端口是 3001,而不是 3002。

该端口通常比运行 Meteor 的端口高 1 (在旧版本的流星的情况下为 2)。例如,如果 Meteor 在端口 3000 上运行,MongoDB 将在端口 3001

于 2014-02-22T10:02:58.497 回答