這是我在CoffeeScript中用於使用MongoDB進行簡單測試的代碼。 當我運行
coffee -c UserDataProvider.coffee
我結束了一個錯誤未封閉INDENT ON LINE 6第6行中的未封閉INDENT(CoffeeScript)編譯器錯誤
這是我的代碼:
Db = require('mongodb/db').Db
ObjectID = require('mongodb/bson/bson').ObjectID
Server = require('mongodb/connection').Server
class UserDataProvider
constructor = (host,port)->
this.db = new Db('test' , new Server(host ,port,{}))
getCollection = (callback) ->
this.db.collection('data',(error,data)->
if error then callback(error)
else callback(data)
堆棧跟蹤是:
Error: In UserDataProvider.coffee, unclosed INDENT on line 6
at Error (unknown source)
at Rewriter.ensureBalance (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/rewriter.js:283:17)
at Rewriter.rewrite (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/rewriter.js:21:12)
at Lexer.tokenize (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/lexer.js:37:29)
at Object.compile (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:26:34)
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:117:33
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26
at [object Object].<anonymous> (fs.js:86:5)
at [object Object].emit (events.js:39:17)
at afterRead (fs.js:843:12)
能
任何人的幫助?
您應該更新代碼才能說'構造函數:'和'getCollection:'而不是用'=',按照你的其他問題在http://stackoverflow.com/問題/ 5124383/another-coffeescript-error就這樣,其他人來到這個頁面不會感到困惑。 :) – 2011-02-26 03:40:33