Reputation: 1162
Trying to load external config file in nodejs for AWS SES with below code.
aws.config.loadFromPath('../config.json');
It throws this error
Error: ENOENT: no such file or directory, open '../config.json'
Now the file is there on that location but above code doesn't see it.
Any quick solution please?
UPDATE
It happens both locally and on the server.
Upvotes: 4
Views: 6745
Reputation: 10135
Use __dirname
let AWS = require('aws-sdk')
const path = require('path')
const dirPath = path.join(__dirname, '/config.json')
AWS.config.loadFromPath(dirPath)
Upvotes: 2