Tag: coffeescript

运行我的应用程序与咖啡与编译它,并将其作为JavaScript运行有什么区别?

目前,我正在运行我的应用程序,像这个coffee app.coffee但我不知道是否将它编译为JavaScript,然后像这个node app.js运行它是一个更好的select。 谢谢

如何debuggingSyntaxError:意外的INDENT错误?

我正在通过peepcode快速教程工作,只是试图跟随,让事情运行,我得到以下错误,当我运行npm开始,似乎是一个咖啡因lib库问题,我确定不想进入与此相关的杂草,关于去哪里的任何想法? [jd@mbp ~/Dropbox/node_projects/tutorials/hot_pie]$ npm start application-name@0.0.1 start / Users / jd / Dropbox / node_projects / tutorials / hot_pie节点server.js /Users/jd/Dropbox/node_projects/tutorials/hot_pie/node_modules/coffee-script/lib/coffee- script/helpers.js:199 throw error; ^ SyntaxError: unexpected INDENT 有什么想法吗? coffescript的版本是"coffee-script": "~1.6.3" v0.10.13 "coffee-script": "~1.6.3" ,节点是v0.10.13

Coffeescript + Express.js:不能调用未定义的方法“切片”

我在express.js和coffeescript中制作了我的第一个应用程序。 代码位于: https : //github.com/findjashua/contactlist 当我尝试运行它时,出现以下错误: /Users/jashua/local/lib/node_modules/coffee-script/lib/coffee-script/helpers.js:216 codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end ^ TypeError: Cannot call method 'slice' of undefined at Object.exports.prettyErrorMessage (/Users/jashua/local/lib/node_modules/coffee-script/lib/coffee-script/helpers.js:216:27) at compileScript (/Users/jashua/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:199:25) at /Users/jashua/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:143:18 at fs.js:266:14 at Object.oncomplete (fs.js:107:15) 我假设这是与contacts.coffee,但不能想到任何东西。 有任何想法吗?

用摩卡testing时,“rest()多次调用”restler错误

当我testing一个restler调用时,我得到一个done()多次错误。 如果我只让restlers调用onece,那不会出错,但是如果我在同一个testing运行中调用同一个方法两次,那么这个错误是错误的。 这里是testing的简化版本 myModule = require 'myModule' describe 'foo', -> describe 'bar', -> it "should hi", (done) -> myModule.hi done it "should hi again", (done) -> myModule.hi done 这里是myModule rest = require 'restler' exports.hi = (done) -> rest.get('http://google.com' ).on "complete", (data, response) -> console.log 'getting called once' done null, data 我应该担心与restler的asynchronous多个请求? 什么是造成这个错误? 控制台日志输出,当我添加 ◦ should […]

在Meteor.startup之前未加载的独立文件中声明的集合在Meteor应用程序中运行服务器端

我刚开始在Mac上使用Meteor。 我做了一个简单的应用程序,在服务器目录中有两个.coffee文件:bootstrap.coffee和publish.coffee。 bootstrap.coffee的内容如下所示: Meteor.startup -> if RaceDays.find().count() is 0 等等。 publish.coffee的内容是: RaceDays = new Meteor.Collection("racedays") Meteor.publish "racedays", -> RaceDays.find() 问题是当我用meteor命令运行应用程序时出现以下错误: 20130917-15:42:00.967(1)? (STDERR /Users/gnidde/Projects/test/.meteor/local/build/programs/server/boot.js:184 W20130917-15:42:00.970(1)? (STDERR) }).run(); W20130917-15:42:00.971(1)? (STDERR) ^ W20130917-15:42:00.979(1)? (STDERR) ReferenceError: RaceDays is not defined W20130917-15:42:00.980(1)? (STDERR) at server/q.coffee:3:5 W20130917-15:42:00.981(1)? (STDERR) at mains (/Users/gnidde/Projects/test/.meteor/local/build/programs/server/boot.js:157:61) W20130917-15:42:00.981(1)? (STDERR) at Array.forEach (native) W20130917-15:42:00.982(1)? (STDERR) at Function._.each._.forEach (/Users/gnidde/.meteor/tools/3cba50c44a/lib/node_modules/underscore/underscore.js:79:11) […]

新的咖啡脚本,运行cakefile时得到产卵ENOENT错误

咖啡剧本我很新。 我正在尝试使用“cake build”命令进行编译。 我得到这个错误。 events.js:72扔呃; 错误:在Process.ChildProcess._handle.onexit(child_process.js:771:34)errnoException(child_process:980:11)处产生ENOENT 这里是我在Windows 7上运行的Cake文件 fs = require 'fs' path = require 'path' spawn = require('child_process').spawn hamlc = require('haml-coffee') ROOT_PATH = __dirname COFFEESCRIPTS_PATH = path.join(ROOT_PATH, '/src') JAVASCRIPTS_PATH = path.join(ROOT_PATH, '/build') log = (data)-> console.log data.toString().replace('\n','') runCmd = (cmd, args, exit_cb) -> ps = spawn(cmd, args) ps.stdout.on('data', log) ps.stderr.on('data', log) ps.on 'exit', (code)-> […]

coffee-script模块如何工作?

出于好奇,咖啡脚本模块如何处理需要'xxx'? 它必须在节点可以加载之前编译所需的文件…它是否具有“require”function的特定处理? 谢谢。

与明文护照:序列化问题与自定义身份validation方法

#set up passport LocalStrategy = require('passport-local').Strategy passport.use(new LocalStrategy({usernameField: 'email'}, (email, password, done) -> User.findOne({ email: email }, (err, user) -> console.log("findone") if err? console.log "error" return done(err) if not user console.log("incorrect username") return done(null, false, { message: 'Incorrect username.' }) if password isnt user.password console.log "NOT" return done(null, false, {message: "Incorrect password" }) console.log "BUT […]

如何使用Express和Node JS构build不区分大小写的REST API

我使用如下所示的快速控制器方法。 如何确认,我可以从{“Name”:“Sam”,“EmpId”:1}或{“name”:“Sam”,“empId”:1} app.post '/api/employee', (req, res) -> employee = new EmployeeModel({ Name: req.body.Name, EmpId: req.body.EmpId }) employee.save (err) -> if (err) res.send err else res.send employee

空inputvalidation不起作用

我一直有一些问题试图获得以下脚本来validationinput。 app = connect() .use(connect.bodyParser()) #So we can get the post data. .use(req,res) -> valid = false if (req.body.name is "") or (req.body.question is "") or (req.body.email is "") #Was all the data submitted? if valid #process request http.createServer(app).listen(1407) 为了debugging我已经使用console.log列出input,它返回两个input,其中一个具有正确的数据,另一个undefined 我以前使用req.body.name? 以及,但它只是重写为req.body.question != null而不是检查未定义。 HTML表单 <form action="_serverurl_" method="post"> <input type="text" placeholder="Your Name" name="name"> <input type="text" […]