小编fiv*_*ven的帖子

Heroku Node.js错误R10(引导超时) - > Web进程在启动后60秒内无法绑定到$ PORT

我找到了十几种针对Express应用程序的解决方案,并设置了端口来监听.但我有一个不使用Express的应用程序,实际上并没有听任何东西.在成功运行60秒后,我收到一条Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch消息.我怎么能绕过它?谢谢.

heroku node.js

17
推荐指数
3
解决办法
2万
查看次数

Mongoose可选搜索查询参数?

我有以下情况.我需要基于某些参数(如果存在)构建一个mongoose查询.

即如果这样的对象被传递

{
    player: "nickname",
    action: "capture"
}
Run Code Online (Sandbox Code Playgroud)

执行以下搜索:

Entry.find({
    player: obj.player,
    action: obj.action
}).
    exec(function(err, res){
        console.log(res);
    });
Run Code Online (Sandbox Code Playgroud)

如果我需要从搜索中排除"操作",如果操作不在对象中,我该怎么办?使用三元运算符一样action: (obj.action) ? obj.action:null不起作用,如将搜索条目DB哪里actionnull.

mongoose mongodb node.js

9
推荐指数
3
解决办法
7349
查看次数

Javascript JSON 解析 unescape 引号?

我有一个用户输入了 JSON 数据,然后将其保存到其他对象。但是我得到的不是 JSON dtExport: '{\\"type\\":\\"polyline\\"}

我该如何解决?谢谢。

javascript json escaping

2
推荐指数
1
解决办法
7209
查看次数

Node.js JSON.parse"Unexpected token {"

我有一个JSON.parse(datastring);用于解析字符串化JSON 的脚本.

datastrings看起来像这样:

{"_id":"8b8fdd243f734b27829c92e4099f70ec.d","date":1439418654920,"player":"player1","action":"capture"}
{"_id":"a3b7d70d8a074f9ba8b13368ee947f1e.d","date":1439418074476,"player":"player1","action":"capture"}
Run Code Online (Sandbox Code Playgroud)

第一个工作正常,但第二个工作得到一个奇怪的错误,我找不到解决方法.

undefined:2
{"_id":"a3b7d70d8a074f9ba8b13368ee947f1e.d","date": 1439418074476,"player":"pla
^
SyntaxError: Unexpected token {
    at Object.parse (native)
    at Socket.<anonymous> (/home/ubuntu/workspace/lib/engine.js:12:18)
    at Socket.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:765:14)
    at Socket.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:427:10)
    at emitReadable (_stream_readable.js:423:5)
    at readableAddChunk (_stream_readable.js:166:9)
    at Socket.Readable.push (_stream_readable.js:128:10)
    at Pipe.onread (net.js:529:21)
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

javascript json node.js

0
推荐指数
1
解决办法
1354
查看次数

标签 统计

node.js ×3

javascript ×2

json ×2

escaping ×1

heroku ×1

mongodb ×1

mongoose ×1