【问题标题】:Cannot find module './config' mean stack找不到模块 './config' 意味着堆栈
【发布时间】:2018-08-22 12:16:24
【问题描述】:

在尝试用 Swagger 连接 mongodb 时,总是 显示

错误:找不到模块'./config'

var mongoose = require('mongoose'),
sw = require('swagger-node-express'),
config = require('./config'),
db = mongoose.connection;

db.on('error', function() {
console.log('Database connection error'.red);
});
db.on('connecting', function () {
console.log('Database connecting'.cyan);
});


mongoose.connect(config.db_url, {server: {auto_reconnect: true}});

【问题讨论】:

    标签: mongodb mongoose swagger mean-stack


    【解决方案1】:

    您的配置文件不在根目录中 它需要与您的 app.js 文件处于同一级别

    【讨论】:

      猜你喜欢
      • 2014-08-23
      • 2020-10-01
      • 1970-01-01
      • 2022-01-10
      • 1970-01-01
      • 2021-02-24
      • 2010-10-22
      • 2020-02-28
      • 1970-01-01
      相关资源
      最近更新 更多