使用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);
答案 0 :(得分:0)
尝试将couchbase
导入您的文件:config/db.js
import config from './env';
import couchbase from 'couchbase'
const cluster = new couchbase.Cluster(config.database.cluster);