I'm having an error saying that EACCES: permission denied, open '/etc/letsencrypt/live/example.com/privkey.pem' while that file can be accessed and modified by the current user that I'm using while running that nodejs project.
I do the answer here and it allows me to access that file, but I'm still having that error when I run my code on pm2, what's wrong here?
My error saying that
{ Error: EACCES: permission denied, open 
    '/etc/letsencrypt/live/example.com/privkey.pem'
    at Object.openSync (fs.js:438:3)
    at Object.readFileSync (fs.js:343:35)
    at Object.<anonymous> (/home/samsung/projects/samsunggalaxy/galaxy/dist/index.js:126:17)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function._load (/usr/lib/node_modules/pm2/node_modules/@pm2/io/build/main/metrics/httpMetrics.js:172:43)
    at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:27:21)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/etc/letsencrypt/live/example.com/privkey.pem' }
While my code on reading the file using nodejs was
import https from 'https';
import { priv_key, cert} from './custom/certs';
const fs = require('fs');
const socket = require('socket.io');
const option = {
    key: fs.readFileSync(priv_key), // '/etc/letsencrypt/live/example.com/privkey.pem'
    cert: fs.readFileSync(cert), // '/etc/letsencrypt/live/example.com/cert.pem'
    requestCert: false,
    rejectUnauthorized: false,
};
option.agent = new https.Agent(option);
const httpsServer = https.createServer(option, app);
const httpsIo = socket.listen(httpsServer)
httpsServer.listen(3005, () => {
    console.log(`started on port ${httpsServer.address().port}`);
});