【发布时间】:2017-07-20 04:41:15
【问题描述】:
我正在开发一个库,我想加载一个或多个与要求程序相关的文件。为了更好地说明这一点:
// ~/app.js
import { horn } from 'unicorn'
horn.load()
// ~/node_modules/unicorn/horn.js
export default {
load() {
require('./user.config.js') // Here I would like to load the user config
// relative to "~/app.js"
}
}
我尝试检查全局 require 及其 parent 属性,但它只给了我一个文件名而没有更多上下文。
【问题讨论】:
标签: node.js configuration configuration-files