Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error loading config.json #2

Closed
bazo opened this issue Jan 6, 2014 · 5 comments
Closed

error loading config.json #2

bazo opened this issue Jan 6, 2014 · 5 comments

Comments

@bazo
Copy link

bazo commented Jan 6, 2014

my folder structure is

root/
   server.js
   config/cnfig.json

i tried to load the config.json, with dot, not dot, slash, no slash

var configurator = new DIConfigurator('./config/config.json');
var configurator = new DIConfigurator('/config/config.json');

i get exception Cannot find module './config/config.json'

workaround i found for this is
var configFilePath = fs.realpathSync('./config/config.json');
var configurator = new DIConfigurator(configFilePath);

but i dont think this is the way it is intended.

@davidkudera
Copy link
Member

Now I finally see, that I really have to do something about this, so thanks for that.

Main problem was with relative paths, because they were relative to DIConfigurator file, not to your calling file. Another problem was that I was not sure if I can do something with this and I was little (little bit more) lazy to find some solution.

But tomorow (ops today) I will change this behavior to expected one.

http://stackoverflow.com/questions/18144921/how-do-i-get-the-dirname-of-the-calling-method-when-it-is-in-a-different-file-in
https://npmjs.org/package/callsite

@bazo
Copy link
Author

bazo commented Jan 6, 2014

thank. it's no big deal.

on unrelated question: is it possible to use multiple config files that would merge together? like in nette main config.neon and local.config.neon?

@davidkudera
Copy link
Member

Now you can use just "includes" section in config (see https://github.com/sakren/node-easy-configuration#including-other-config-files).

But I think that you meant config files for different environments right? Like developmnent and production... If I'm right, can I ask you to write new issue please?

@davidkudera
Copy link
Member

I just figured out that there will be problem with browser support, where paths will need to stay absolute (probably).

Better documentation will be also needed.

@davidkudera
Copy link
Member

@bazo i just released new version 2.2.0 with support for relative paths.

I also updated module easy-configuration. And there I added among others support for different environments (or better sections to load - development, production, ...).

If you want to use other config files (or sections from config files) you will have to follow these steps and read documentation here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants