I am trying to read a local file using node.js. My NPM module is trying to execute a child process and that inturn opens a file to read. While reading this throws an error
{ [Error: ENOENT, open 'E:\Project\SecIntegrator\Attack\manifest.json']
errno: 34,
code: 'ENOENT',
path: 'E:\\Project\\SecIntegrator\\Attack\\manifest.json' }
Actual path to read this file is
E:\Project\SecIntegrator\node_modules\restScannerDriver\GarudRudra\Attack\manifest.json
I have used var configPath = path.join(path.dirname(fs.realpathSync(__filename)), '/'); to calculate absolute path but still not working.
Inside the NPM module your path changes. So try to use __dirname in NPM and create the realpath like that:
var filepath = fs.realpathSync(__dirname+'/'+relative path from here to your file);
After that look what's the result of filepath