In your .env
file add
USER=www-data
Note: I have choose to run node as the user www-data
you can choose any other appropriate one.
Now Run
$ npm i userid --save
At the top of your app.js or index.js file add
const userid = require('userid');
const user = process.env.USER;
const uid = parseInt(user), 10);
// Set server's uid to that user
if (uid) {
process.setuid(uid);
}
Leave a Reply