运行命令migration-mongo up时导入库错误

问题描述

我为项目插入了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;
那就是带有用于连接到db的配置数据的文件:
// @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 (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...