Unclosed INDENT on line 6 (CoffeeScript) Compiler Error

Here is my CoffeeScript code for a simple test with MongoDB. When I start coffee -c UserDataProvider.coffee
I get the 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)

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)

Can anyone help?

+3
source share
2 answers

The first left bracket on this line never closes:

this.db.collection('data',(error,data) ->

In fact, this is not necessary at all, so you probably want to delete all this together if you intend to pass the "data" as the first argument and function(error, data) { ... }as the second argument.

+4
source

FYI, a useless error message is a bug in the current version.

+1

Source: https://habr.com/ru/post/1794836/


All Articles