Tag: coffeescript

在node.js中使用与SASS的连接资产

我在节点应用程序中使用connect-assets模块,无法使用node-sass模块使用sass。 我可以把它与咖啡剧本合作。 在我的server.coffee文件中 require "node-sass" connectAssets = require 'connect-assets' @_app.use connectAssets(src: __dirname + "/app/assets", jsDir: 'js', cssDir: 'css') 在我的玉石视图中我有: != css('reset') 在页面加载时出现以下错误:“找不到路由css / reset.css的文件”这是我为testing而放入的唯一sass文件,它按照文档指南命名:reset.css.scss 我在前端使用完全相同的咖啡文件处理过程,效果很好。 我也用较less的模块尝试了这一点,我也得到了相同的结果。 我在这里错过了一步? 在这个过程中我能find什么小小的文档,听起来像是一个非常微不足道的任务,我不知道我做错了什么。

为什么require()会给我一个从不同位置加载的模块的新副本?

我很新的Node.JS发展,我试图创build一个Hubot适配器。 hubot模块导出一个名为TextMessage的类,我需要使用它。 在我的适配器中,我创build了一个实例并将其传递给运行的机器人,如下所示: {Adapter, TextMessage} = require 'hubot' class MyAdapter extends Adapter onNewMessage: (text) => @receive new TextMessage text 但是, 在Hubot自己的代码中,它检查我的消息是instanceof TextMessage一个instanceof TextMessage 。 当我运行一个bot并使用我的适配器时,这个检查总是失败。 项目结构如下所示: my-bot |- node_modules |- my-adapter | |- node_modules | | |- hubot |- hubot 因此,在my-adapter require('hubot')给我一个hubot模块的副本,就像给my-bot 。 我很确定我不了解Node模块的一些基本概念。 我究竟做错了什么?

Superagent在asynchronous瀑布中移动响应callback位置

我有一个简单的工作superagent / async瀑布请求,看起来像这样: request = require 'superagent' user = request.agent() async.waterfall [ (cb)-> user.post('http://localhost:3000/form').send(name: 'Bob').end(cb) ], (err, res)-> console.log err console.log res 这成功地打印我的完整http响应,而err是undefined 。 如果我用一个额外的步骤完成同样的事情: request = require 'superagent' user = request.agent() async.waterfall [ (cb)-> user.post('http://localhost:3000/form').send(name: 'Bob').end(cb) (err, res)-> # this is never reached cb() ], (err, res)-> console.log err # this now prints out […]

util.inherits in coffeescript

我正在使用Node.js服务器,并使用咖啡脚本进行开发。 这是如何工作咖啡脚本? EventEmitter = require('events').EventEmitter util.inherits(Connector, EventEmitter) 是吗? EventEmitter = require('events').EventEmitter class @Connector extends EventEmitter 我基本上试图添加emit到Connector 。 就像是: this.emit('online')

指定由节点中的hubot创build的GET请求的callback函数

我们当地的Hubot(“Sparky”)运行大量的插件脚本,并且一般运行良好。 我正在写一个插件脚本,对Yahoo Pipes进行GET调用,并期待JSONP的结果。 但是,我不确定如何使用_callback参数。 码: module.exports = (robot) -> robot.hear /\bkeyword\b/i, (msg) -> robot.http("http://pipes.yahoo.com/pipes/pipe.run") .query({ _id: "legit-pipe-id-is-here", _render: "json", _callback: "?" }) .get() (err, res, body) -> if body? data = JSON.parse(body) 这得到的错误是: undefined:1 _({"count":10,"value":{"title":"correct title","description":"Pipes Output","lin ^ SyntaxError: Unexpected token _ at Object.parse (native) at e:\node\sparky\scripts\plugin-name.coffee:26:11, <js>:11:23 at IncomingMessage.<anonymous> (e:\node\sparky\node_modules\hubot\node_modules\scoped-http-client\lib\index.js:70:20) at IncomingMessage.EventEmitter.emit (events.js:117:20) at […]

当node-amqp没有exception

我正在尝试使用node-amqp。 当在连接到兔子的部分抛出一个exception,我可以得到这个exception,但它永远重新启动连接到兔子。 看那个: amqp = require("amqp") # Open a connection conn = amqp.createConnection( {url: "amqp://localhost"} , {reconnect: true}) conn.on "ready", -> console.log "Conn Ready" conn.queue "queueX", {ack:true}, (queue) -> console.log "Subscribed #{queue.name}" assdsd() #calling non-exiting method. No exception is thrown but the connection is restarted 系统循环引发错误。 我知道这是因为{recconnect:true}。 但我希望能够自行处理例外情况。 任何想法? 我的脚本的输出是这样的: Conn Ready Subscribed queueX Conn […]

与Thunkify +mongoose的KoaJS

我正在做我的第一个koajs项目,理解(或试图)发电机function,产量,thunk等。我遇到了一个与mongoose(我严重依赖)的问题。 search论坛后,解决scheme是thunkify: CoffeeScript的: Controller = require './basecontroller' User = require '../models/user' UserController = ((c, User) -> return ( get: (next) -> userQuery = c.libs.thunkify User.find try users = yield userQuery {} @body = users return catch e console.error "Error: #{e}" throw e return next() ) ) Controller, User # Export functionality module.exports = UserController JavaScript的: […]

Coffeescript和nodeJS中的常量

我应该如何保持常量? 例如,我在Github中看到了很多代码,其中表名,行等只是在coffeescript类的方法中被硬编码。 如何进行这样的常量,如何保持它们? 以及如何保持模块之间共享的常量,枚举。 我想我应该创build单独的类只暴露常量,对不对? 最后,在分布式应用的情况下,在服务之间保持常量和枚举的方法是什么? 例如,项目可以由几个应用程序组成,这些应用程序使用套接字相互通信。 我应该创build另一个只显示常量的应用程序吗? 如果是的话,这个解决scheme的性能影响是什么?

Coffescript + Ionic

我期待在CoffeeScript中使用Ionic框架构build混合移动应用程序。 该应用程序的function是login/注册; 把图片上传到mongodb中存储。 什么是这个应用程序的完整堆栈build议? https://github.com/diegonetto/generator-ionic覆盖了客户端(除了在JavaScript中,我将find一种方法使其与CoffeeScript一起工作) 在服务器端; mongoose+护照+我还需要什么? https://github.com/malikov/Authenticate.me-client-cordova-ionic https://github.com/malikov/Authenticate.me-Node-Server

aglio API蓝图渲染安装错误

我正在尝试安装aglio, https: //github.com/danielgtaylor/aglio,由于出现错误,无法继续前进。 npm ERR! Failed at the protagonist@0.17.1 install script 'node-gyp rebuild'. 我的服务器是cento OS 6.5, 我按照这里的说明安装节点js https://www.digitalocean.com/community/tutorials/how-to-install-and-run-a-node-js-app-on-centos-6-4-64bit 然后显示咖啡脚本1.8.0没有find另一个错误。 我把它安装成npm install -g coffee-script 所以请build议我如何摆脱这个错误。 这是关于错误的完整信息。 [root@hellop ~]# npm install -g aglio npm WARN optional dep failed, continuing fsevents@0.3.1 > ws@0.5.0 install /usr/local/lib/node_modules/aglio/node_modules/socket.io/node_modules/engine.io/node_modules/ws > (node-gyp rebuild 2> builderror.log) || (exit 0) ^C[root@hellop ~]# npm install aglio […]