Monday, 24 April 2017

SyntaxError: Unexpected identifier in node

i try to fetch data from mongodb database using nodejs and mongorito orm for mongodb database, but its show me following error

kaushik@root:~/NodeJS/application$ node run.js 
/home/kaushik/NodeJS/run.js:16
        var posts = yield Users.all();
                          ^^^^^
SyntaxError: Unexpected identifier
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)
    at startup (bootstrap_node.js:147:9)
kaushik@root:~/NodeJS/application$ 

here is run.js

var Mongorito = require('mongorito')
var Model = Mongorito.Model

var Users = Model.extend({
    collection: 'testing'// collection name
});
var posts = yield Users.all();
console.log(posts)

i also try 'use strict' but its give following error

SyntaxError: Unexpected strict mode reserved word



via Kaushik Makwana

No comments:

Post a Comment