第 6 行中未闭合的 INDENT ( CoffeeScript ) 编译器错误
这是我在 CoffeeScript 中的代码,用于使用 MongoDB 进行简单测试。 当我跑步时咖啡-c UserDataProvider.coffee
我最终得到一个错误 UNCLOSED INDENT ON LINE 6
这是我的代码:
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)
StackTrace 是:
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)
任何人都可以帮忙吗?
Here is my code in CoffeeScript for a simple test with MongoDB.
When I runcoffee -c UserDataProvider.coffee
I end up with an error UNCLOSED INDENT ON LINE 6
This is my code:
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)
The StackTrace is:
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)
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该行的第一个左括号永远不会关闭:
实际上根本不需要它,因此如果您的目的是将“data”作为第一个参数传递,并且
function(error , data) { ... }
作为第二个参数。The first left parenthesis on this line is never closed:
It is actually not needed at all, so you probably want to remove it all together, if your intention is to pass "data" as the first argument and the
function(error, data) { ... }
as the second argument.仅供参考,无用的错误消息是当前版本中的错误。
FYI, the unhelpful error message is a bug in current version.