Tag: coffeescript

不能在节点中需要coffee-script

我已经通过nvm安装了coffeescript和node 。 但是,当我在Node.js控制台中需要咖啡时,出现错误: var cs = require('coffee-script/register'); // => Error: Cannot find module 'coffee-script/register' 要么 var cs = require('coffee-script'); // => Error: Cannot find module 'coffee-script' 我的环境: node -v // => v5.0.0 coffee -v // => CoffeeScript version 1.10.0 npm list -g coffee-script // => ~/.nvm/versions/node/v5.0.0/lib // => └── coffee-script@1.10.0 我认为这个问题正在导致像这样的其他错误: knex –help // => […]

直接向机器人发送消息时,Hubot脚本只能在Slack中工作

现在,我的Hubot机器人正在娴熟地工作。 如果我将这条消息直接传递给Slack中的机器人: qbot !npm bower 它会回复这个链接: https://www.npmjs.com/package/bower 它也适用,如果我只是这样做: !npm bower 但是,如果我在通道中提到这两条消息中的任何一条,机器人就不会做任何事情。 任何帮助,将不胜感激! 这个脚本如果有帮助的话: # Description: # Get a link to an npm module # # Dependencies: # request # # Configuration: # None # # Commands: # qbot !npm <module> request = require "request" module.exports = (robot) -> robot.hear /\!npm (.*)/i, (res) -> module = […]

将async.eachLimit转换为promise

我有这样的同步代码 async.eachLimit(teams, 1000, fetchTeamInfo, exit) 我需要将其转换为Promise(蓝鸟) 我认为会很好做出类似于: Promise.method (teams, 1000, fetchTeamInfo) -> async.parallelLimit arr.map((a, i) -> -> iterator a, i, arr ), limit 但不确定是否正确

pipe道订购事宜? 将标准input传输到http请求中,并将结果传送到标准输出

我正在看“http客户端” 我做出了通过2/3testing的以下解决scheme: request = require 'request' #Generate a read/writable stream piping into the outbuff myRequest = request.post("http://localhost:8099").pipe(process.stdout) process.stdin.pipe(myRequest) …出现以下错误: operator: equal expected: 'azzwcc\njup\nvccvwcddun\nmukp\nikeos.\nPaps\'w\nheghuuyuuv\nwu\nbzcawcsenvzm\nouggkneoasc\n' actual: 'allsee\nfor\ndeedsetton\nyour\nquick.\nTark\'s\nbimboowood\nso\npleasekindly\ncommunicake\n' 但是,当我按这个顺序输出输出时,它工作正常。 request = require 'request' #Generate a read/writable stream piping into the outbuff myRequest = request.post("http://localhost:8099") process.stdin.pipe(myRequest).pipe(process.stdout) 这两个解决scheme不应该一样吗? 我在这里错过了什么?

Node.js和ES6

我想开始在Node.js上使用这个ES6,但我不能让它工作。 我正在添加node test.js –harmony标志,但是我仍然遇到了错误的语法错误。 它甚至不传递第一行代码: import env from 'node-env-file' import api from '../src' 我得到这个 (function (exports, require, module, __filename, __dirname) { import env from 'node-env-file' ^^^^^^ SyntaxError: Unexpected token import 我怎样才能让我的Node.js使用这种types的语法。

Swagger UI不发送url的参数

我正在构build一个使用MongoDB和mongoose的应用程序的api,我正在使用Swagger UI来testing它,我做了一个删除路线: app.delete '/venues/:id', venueController.delete venueController.delete看起来像这样(在coffeescript): exports.delete = (req, res) -> console.log req.params.id Venue.remove id: req.params.id .then (dbVenue) -> res.json dbVenue .catch (err) -> console.log err res.sendStatus(500).end err.message 在swagger UI中我input一个id并发送删除请求,但是req.params.id的console.log只是吐出":id"而不是我input的id。 我该如何解决?

npm ERR! 无关的:pug@2.0.0-alpha6

我需要一些帮助。 我只是学习用node.jsbuild立一个网站。 我已经安装了节点v4.5.0,npm 2.15.9,coffeescript 1.10.0我正在按照书“CoffeeScript和Node.js”的说明操作。 我有这个文件package.json : { "name": "todo", "version": "0.0.1", "private": true, "scripts": { "start": "node app" }, "dependencies": { "express": "3.0.0beta6", "jade": "*", "socket.io": "*", "coffee-script": "*", "connect-assets": "*" } } 我运行命令: npm install ,之后显示了一些警告,关于jade被弃用,并且必须安装pug 。 我在package.json文件中改变了package.json ,然后再次运行npm install 。 又有一些警告,关于更新版本的pug ! 再次做了一些改变,最后这个ERR出现了! 我会感谢一些帮助,如何继续下去。 注意: 示例代码来自相当古老的一本书(2012年),从未更新过。我应该如何继续? 我有一个目录树, jade 和 pug 。 这会工作吗? […]

NodeJS:保持库文件干燥

我最近开始在CoffeeScript中开发一个不平凡的项目,我正在努力处理注册输出等问题。我正在以非常“pythonesque”的方式编写它,个人文件有效地被称为“模块”相关的类和function。 我正在寻找的是在本地和在exports / window中尽可能less地重复定义类和函数的最佳方式。 目前,我在每个文件中使用以下内容,以节省写入exports.X = X文件中的所有内容: class module # All classes/functions to be included in exports should be defined with `@` # Eg class @DatClass exports[name] = item for own name, item of module 我也研究过使用一个函数(比如publish ),根据名称将传入的类放在exports / window中的可能性: publish = (f) -> throw new Error 'publish only works with named functions' unless f.name? ((exports […]

将coffeescript合并到你的节点项目中?

设置一堆观察者来编译js仍然是开发中最好的方法还是有更优雅的东西? 我正在寻找处理开发中的CoffeeScript的技术或包,使它真的很好,而不是只是看着和编译到另一个js文件夹。 什么都有 感谢您的任何想法!

节点asynchronous库绑定这个

我正在使用asynchronous库( https://github.com/caolan/async )在节点上尝试执行与mongoskin( https://github.com/guileen/node-mongoskin )asynchronous的多个db查询 问题是使用像这样的地图function app.post '/events', (req, res) -> storage.events.getByUser req.session.authId, (events) -> async.map events, storage.codes.getCountByEvent, (err, results) -> res.send results 它将@绑定到getCountByEvent函数上的全局名称空间,是否有任何具有asynchronous库经验的人能够给我指导最好的方法来解决这个问题? 这是storage.codes实现的示例 class Codes constructor: (db) -> db.bind 'codes', getCountByEvent: (event, callback) -> @.find(event: event._id).toArray (err, res) -> callback res.length return db.codes exports.Codes = Codes 调用getCountByEvent之外的async.map它会正常工作 提前致谢