couchbase配置集群undefined

时间:2017-05-27 11:32:13

标签: node.js ecmascript-6 koa

使用couchbase数据库,我在config/db.js

中收到此错误
var cluster = new _couchbase2.default.Cluster(_env2.default.database.cluster);
TypeError: Cannot read property 'cluster' of undefined

配置/ ENV / development.js:

const config = {
    database: {
        cluster: '...',
        password: '',
        bucket: '...'
    }
}

export default config;

配置/ ENV / index.js:

const env = process.env.NODE_ENV || 'development';
const config = require(`./${env}.js`);

export default config;

配置/ db.js:

import config from './env';

const cluster = new couchbase.Cluster(config.database.cluster);

1 个答案:

答案 0 :(得分:0)

尝试将couchbase导入您的文件:config/db.js

import config from './env';
import couchbase from 'couchbase'

const cluster = new couchbase.Cluster(config.database.cluster);