joyent/node — Issue #2184: require("./configuration.json"): module not found
Author: tylermwashburn
Created: 2011-11-25 03:19:47+00:00
State: open

I'm having the weirdest problem.

I'm writing an app called Book. It's directory based, and when first run in a directory creates a subdirectory called .book, which holds configuration files, etc.

I've tried two methods to load the configuration.

The native way..

config = path.existsSync( ".book/configuration.json" ) ?
require( "./.book/configuration.json" ) :
{}

..doesn't work. But the workaround way..

config = path.existsSync( ".book/configuration.json" ) ?
JSON.parse( fs.readFileSync( ".book/configuration.json", "utf8" ) ) :
{}

..works just fine.