加载配置文件时Express / Node应用程序问题

时间:2014-09-17 01:52:16

标签: node.js

在我的文件app/controllers/activities.coffee中,我正在尝试加载我的配置文件:

cfg = require '../config/config'

但我一直收到这个错误:

Error: Cannot find module '../config/config'

以下是该文件的外观(/config/config.coffee):

path     = require 'path'
rootPath = path.normalize __dirname + '/..'
env      = process.env.NODE_ENV || 'development'

config =
  development:
    root: rootPath
    app:
      name: 'app'
    port: 3000
    db: 'mongodb://localhost/app-development'

  test:
    root: rootPath
    app:
      name: 'app'
    port: 3000
    db: 'mongodb://localhost/app-test'

  production:
    root: rootPath
    app:
      name: 'app'
    port: 3000
    db: 'mongodb://localhost/app-production'


module.exports = config[env]

1 个答案:

答案 0 :(得分:1)

如果你尝试怎么办?的 ../../配置/配置