Phantom,Casper和Meteor为什么需要自己的可执行文件?

幻影 和meteor都是build立在节点之外的,卡斯帕是build立在幻影之外的。 为什么他们每个都需要自己单独的可执行文件,而不是通过Node.js来创build库? (我发现这使得它们更难以使用,特别是在Windows上)。

为什么NodeJS KeepAlive似乎没有按预期工作?

从TCP keepalive引用HowTo : 为了了解什么是TCP keepalive(我们将其称为keepalive),您只需要读取名称即可:keep TCP alive。 这意味着您将能够检查连接的套接字(也称为TCP套接字),并确定连接是否仍在运行或者是否已损坏 。 那么为什么下面的代码不会在互联网连接断开的时候抛出一些东西 ? var tls = require('tls'); var socket = tls.connect(443, "google.com", function connected() { console.log('connected'); }); socket.setNoDelay(true); socket.setKeepAlive(true, 0); socket.setTimeout(0, function(){ console.log('timeout'); }); socket.on('data', function(data) { console.log(data); }); socket.on('close', function() { console.error("close"); }); socket.on('error', function(err) { console.error("error", err); }); 使用NodeJS v0.10.17在MacOS / Debian上进行testing

在NodeJS中dynamic构buildMongoDB查询

我收到一个POST参数,如下所示: sort: [ { field: 'name', dir: 'asc', compare: '' }, { field: 'org', dir: 'asc', compare: '' } ] } 我需要创build一个基于MongoDB的查询,所以它应该是这样的: db.collection("my_collection").find( … ).sort({'name': 'asc', 'org': 'asc'}).toArray(…); 不pipe怎样,请记住,可以传递更多的字段。 此外,可能会发生这些字段都没有传递,这意味着查询不会有.sort() 。 我的问题:我如何dynamic创build一个查询与节点的MongoDB驱动程序? 有没有查询生成器或类似的东西?

Sails.js:如何在bootstrap中使用i18n

如何在Sails.js的bootstrap中使用i18n? 这里是控制器动作中的“res.i18n”,但是我没有find像sails.i18n这样的全局实例(已经初始化)。 我猜下面的代码应该在bootstrap.js中工作: i18n = require('i18n'), i18n.configure({ locales: sails.config.i18n.locales, directory: sails.config.appPath + sails.config.i18n.localesDirectory, defaultLocale: sails.config.i18n.defaultLocale, updateFiles: false, extension: '.json' }); __('Hello'); 但是可能有更好的办法吗?

把手中的“玉块”相当于

车把与玉石块有相同的function吗? 我知道它有局限性,但是我不明白如何用部分模型来模仿玉石的function。 下面是我想用玉来完成的一个例子: 主模板: // layout.jade doctype 5 html head title= title link(rel='stylesheet', href='/stylesheets/style.css') block head body header block header block content footer block footer block scripts 其他模板: // camera.jade extends layout block head link(rel='stylesheet', href='/stylesheets/camera.css') block header h1 Camera block content section#secScreen video#vdoScreen aside#asdControls nav a(href='/') Back a(href='') Refresh a(href='/gallery') Gallery block scripts script(src='/javascripts/camera.js') […]

如何在node.js javascript中限制对apis的访问?

我做了一些研究,找不到任何能让我成功的事情。 所以,我用require(..)从外部脚本加载.js ,每个脚本导出一个函数.. main.js var main=10; var mod1 = require("./mod1.js"); mod1.js module.exports=function(){ console.log('loaded'); var net=require('net'); // i don't want it to be able to require certain node.js apis net.create…; } 我看到了一些.json文件声明permissions ,如果是的话,它授予对脚本的访问权限。 核心node.js apis是如何实现的?

共享Socket.IO和WS之间的WebSocket连接

为了能够在使用Socket.IO的RPCfunction的同时发送二进制数据,我想我可以在同一台服务器上同时使用Socket.IO和WS模块。 而不是打开完全独立的服务器来build立两个连接,我想知道我是否可以使用相同的HTTP服务器。 是否可以同时使用一个由http.createServer()为Socket.IO和WS创build的服务器? 很明显,我期望从客户端创build一个Socket.IO连接和一个常规的WebSocket连接。 下面的代码在客户端创build协议错误,大概是因为Socket.IO和WS都试图处理连接。 var http = require('http'); var server = http.createServer(app); server.listen(3000); // Socket.IO var io = require('socket.io').listen(server); io.sockets.on('connection', function (socket) { // … } // ws var WebSocketServer = require('ws').Server var wss = new WebSocketServer({server: server}); wss.on('connection', function (ws) { // … }

重新启动后找不到npm命令

计算机重新启动后, npm命令不断被识别: -bash: npm: command not found node命令仍然正常工作,这只是npm不工作。 我必须从主站点重新安装Node.js才能重新运行。 ~/bin被添加到我的$PATH在我的.bash_profile与: export PATH="$HOME/bin:$PATH" 编辑:我也使用完整的mathiasbynens / dotfilespipe理自己的版本,我不知道这里是否有冲突。

NodeJS本地驱动程序上的示例MongoDB错误是什么样的?

我似乎无法find他们的文档或在互联网上的任何MongoDB错误对象的例子。 什么是一个示例MongoDB错误对象的样子? 我想“处理”错误和/或重新格式化它为我自己的目的,这取决于错误是什么。

Bookshelf.js或Knex.js中的2个表的外连接

我是Bookshelf.js和knex的新手。 我需要在Bookshelf / knex中写一个相当于这个的查询 SELECT Inv.*, Comp.* FROM Inv, Comp WHERE Inv.uId =2 AND Comp.cId = Inv.cId; 发表表格有: Id | 主键,整数不为空 col1 | string数据 cId | 整数,外键引用C表 uId | 整数外键引用U表 比较表有: cId | 主键,整数不为空 col3 | string数据