问题描述
我为项目插入了migration-mongo,并且需要从文件中导入数据以进行配置以连接到db。在此文件中,我导入了库“ merge”。
但是在启动命令“ migrate-mongo up”时,我遇到了错误,名称为“错误:意外的标识符”。
当我m using debug,I have error 'ReferenceError: merge is not defined at eval' That
编写代码时:文件'migrate-mongo-config.js'
const configFile = require('../src/config/index');
const { db } = configFile;
const {
userName,password,host,port,name,} = db;
const credential = userName ? `${userName}:${password}@` : '';
const url = `mongodb://${credential}${host}:${port}/${name}`;
const config = {
mongodb: {
url,databaseName: name,options: {
useNewUrlParser: true,// removes a deprecation warning when connecting
useUnifiedTopology: true,// removes a deprecating warning when connecting
// connectTimeoutMS: 3600000,// increase connection timeout to 1 hour
// socketTimeoutMS: 3600000,// increase socket timeout to 1 hour
},},// The migrations dir,can be an relative or absolute path. Only edit this when really necessary.
migrationsDir: 'migrations',// The mongodb collection where the applied changes are stored. Only edit this when really necessary.
changelogCollectionName: 'changelog',// The file extension to create migrations and search for in migration dir
migrationFileExtension: '.js',};
// Return the config as a promise
exports = config;
// @flow
const merge = require('merge');
const config = require('./config');
type AppConfig = {
port: number,db: {
userName: string,password: string,host: string,port: string,name: string,};
const ENV = process.env.NODE_ENV;
const appConfig: AppConfig = merge.recursive(true,config.common,config[ENV || 'local']);
module.exports = appConfig;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)