unexpected strict mode reserved word — yield? Node v0.11, harmony, es6

前端 未结 2 1976
感动是毒
感动是毒 2021-02-01 17:21

Trying to use a new ES6 based node.js ODM for Mongo (Robe http://hiddentao.github.io/robe/)

Getting \"unexpected strict mode reserved word\" error. Am I dong something w

2条回答
  •  滥情空心
    2021-02-01 17:29

    Also noteworthy... new versions of co return/use promises rather than thunks. So this is what worked with newer versions of co.

    var co = require('co');
    
    co(function*() {
        "use strict";
    
        { let a = 'I am declared inside an anonymous block'; }
    
        var Robe = require('robe');
    
        var db1 = yield Robe.connect('127.0.0.1/swot');
        console.log(db1)
    
        return db1;
    
    }).then(function (value) {
        console.log(value);
    }, function (err) {
        console.error(err.stack);
    });
    

提交回复
热议问题