In your .env file add


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) {