Tag: 节点.js

你可以更改tonicdev.com上的节点版本吗?

Tonic允许您在浏览器中运行节点代码… https://tonicdev.com/ 但是它目前运行的节点数是0.12.7 您可以在使用Tonic时更改节点版本吗? 我已经search,但无法find任何东西 – 以为现在有人可能。 我的npm模块在节点4以下的任何地方都失败。

如何处理compoundjs中不同命名空间的单独布局

嘿家伙,我是一个刚刚开始在nodejs工作的noob。 我正在开发一个使用复合jj的nodejs上的web应用程序。 这是我的视图文件夹的结构 views/ |– admin | |– games | |– squadplayertypes | `– toursection | |– tourformats | |– tourmatchtypes | `– tours |– layouts | |– admin | | `– toursection 我创build了一个名称空间来处理所有针对“/ admin”的请求。 现在我想知道是否有可以在命名空间“admin”中为所有路由定义通用布局的地方。 这是我写我的routes.js admin.namespace('toursection', function(toursection){ toursection.resources('tours',function(tour){ tour.post('fetchTourDetails','tours#fetchTourDetails',{collection:true}); }); toursection.resources('tourmatchtypes'); toursection.resources('tourformats'); }); /*Routes for squad players and all related dependancies*/ admin.resources('squadplayers');

Node.js TypeError:res.json不是一个函数

我试图创build一个简单的Hello World应用程序使用Swagger和Node.js打印出“你好”,当我打电话给GET,但我得到的错误: TypeError:res.json不是一个函数 。 使用Swagger编辑器,我创build了以下yaml api: — swagger: "2.0" info: version: "1.0.0" title: "Hello World" paths: /hello: get: x-swagger-router-controller: "hello_world" description: "Returns 'Hello' to the caller" operationId: "hello" parameters: – name: "name" in: "query" description: "The name of the person to whom to say hello" required: false type: "string" responses: 200: description: "Returns greeting" schema: […]

在parsing之前返回的延迟对象

我正在使用带有Node js的库。 我创build一个被caching的对象,把这个parsing放到一个封装的Mongoose findOne()函数中,然后在外面返回promise。 但似乎我的承诺总是在数据被检索之前返回。 User.prototype.getProfile = function(criteria) { var deferred = when.defer(); var options = { criteria: criteria, select: 'name id email' }; this.User.load(options, function(err, data) { if (data) { this.name = data.name; this.email = data.email; this.id = data.id; } else { return false; } console.log(data); deferred.resolve(); }); console.log('returning promise'); return deferred.promise; }; 呼叫者 […]

如何在Atom中安装Jade语言支持

我正在使用Atom,我想创build所有我的新应用程序。 不过,我注意到Atom不支持Jade。 我是谷歌search,我所知道的只是一个包。 https://atom.io/packages/atom-jade 这是 “最初从Jade TextMate包转换而来,并且适用于Atom。” 但是,我不知道如何安装它。 另外,在github项目和其他任何地方,我都看不出有什么关系。 Debian或类似的 我感谢任何帮助。 谢谢

在类select器上LESS“无法识别的input”有什么可能的原因?

LESS正在投掷 ParseError: Unrecognized input in [filepath] on line 120, column 3: 119 .transition(width 0.32s, height 0.32s, left 0.32s, top 0.32s); 120 .room { 121 display: inline-block; 第3列是. 。 我查看了我的代码,找不到任何理由。 在没有改变结果之前评论说明。 在下一个级别声明中.room{及其匹配的结果}被标记,同样莫名其妙。 我已经做了一些研究,但是大部分关于“无法识别的input”的信息都与@import声明或variables的使用有关,这两者我都没有做。 因为LESS可能会涉及很多,所以我为自己的问题编写了一个回购协议: https : //github.com/theqwertman/less-sample-for-debugging 使用全球通过NPM安装的LESS版本1.7.5。

节俭js:节点 – 不能使用保留语言关键字:“不”

转换nodejs的节点对象时: thrift -r –gen js:node state_service.thrift 引发以下错误: [错误:/state_service.thrift:33](最后一个标记是'不')不能使用保留语言关键字:“不” 代码中的33行是: typedef bool Not struct Exp { 1: string left 2: Not not 3: BinaryOp op 4: AnyValue right } 我正在使用最新的Thrift 0.9.2版本

在Node.js中处理未处理的拒绝

跟进问题重新。 陷阱when.js未处理的拒绝 Node.js process.on()示例阻止正常的console / prettymonitor输出显示。 有没有办法保留这一点。 另外文档显示:process.on('unhandledRejection',function(reason,key)not ..(promise,reason)。ref: http : //github.com/cujojs/when/blob/master/docs/debug- api.md

crypto createHMAC输出根据nodejs版本的不同而不同

在升级我的节点版本时,我遇到了encryption模块问题。 创build的HMAC取决于节点的版本。 您会在下面find重现问题的代码。 如果我将密钥编码为BASE64(或任何),则HMAC不依赖于node.js版本。 如果我把它编码为二进制,如果我改变我的node.js版本,HMAC是不同的。 [编辑]根据为什么crypto.createHash在新版本中返回不同的输出? 调用update函数时添加了编码 代码片段 "use strict"; const crypto = require('crypto'); console.log(process.version); let key = '5ece799aa73a7a8e687876f8e0eabe2e200b967ef5728d845f72fc9ea27dbcd90cd4e06e8bc90d823ac8a54ce91f68ca37fc2e7bbf3f5ef9d82b4c6b938f1936'; let _key64 = (new Buffer(key, 'hex')).toString('base64'); console.log("B64 KEY: "+crypto.createHmac('sha512', _key64).update("hey", "binary").digest('hex').toUpperCase()); let _keyBin = (new Buffer(key, 'hex')).toString('binary'); console.log("BIN KEY: "+crypto.createHmac('sha512', _keyBin).update("hey", "binary").digest('hex').toUpperCase()); 输出是以下两个版本的node.js v5.6.0 B64 KEY: 0DC11C737E575B17DD575042F8F372E3D63A86C3B56C06FB74C9B0AB8E96A5FC8A2DC33667280DC5B306C93AA3DECBAF0D8EDE56F3666C11BFC25A70CFC027D0 BIN KEY: E5A9F813D9AA64A6791BEA91035553FFC730DBE635D0CE7AC722C0195DFDD77A969323FDDFB4E5054E59073DAE9B9BF00CFF73CF20F2FACEE01F79F25E7B9303 v8.1.4 B64 KEY: 0DC11C737E575B17DD575042F8F372E3D63A86C3B56C06FB74C9B0AB8E96A5FC8A2DC33667280DC5B306C93AA3DECBAF0D8EDE56F3666C11BFC25A70CFC027D0 BIN KEY: […]

如何通过CompoundJS中的“使用”方法传递参数?

我正在使用CompoundJS(Express / NodeJS的MVC)。 为了在控制器之间共享代码,Doc说在controller1.js我可以使用publish方法来共享一个方法: /***controller1.js***/ function sharedFunction () {…} publish('sharedFunction', sharedFunction); //Sharing… 在controller2.js我可以通过load它并尝试use方法来访问它: /***controller2.js***/ load('controller1'); // _controller siffix must be omitted use('sharedFunction') 问题 这很好,但是,我有一个sharedFunction有params: /***controller1.js***/ function sharedFunction (param1, param2) {…} publish('sharedFunction', sharedFunction); //Sharing… 我一直在阅读文档,但是我找不到如何,或者语法,在controller1.js上的use方法上添加这个参数。 我在哪里发送这些参数? : /***controller2.js***/ load('controller1'); // _controller siffix must be omitted use('sharedFunction(params here?)', {params here?}) //where do I send the params? 非常感谢你!