In Linux we can detect ubuntu and its version like Ubuntu 18.04.4 LTS using Linux command “lsb_release -a | grep Description”, using nodejs child_process we can easily run Linux command and detect Linux version.
Code to detect Ubuntu and its version using Nodejs in Linux
The blow code is tested on Node JS Version : 12.4.0
/* by Sanjay Prasad */ const { exec } = require('child_process'); exec('lsb_release -a | grep Description', (err, stdout, stderr) => { if (err) { console.error(err) } else { console.log("stdout" +stdout.slice(12)); console.log(`stderr: ${stderr}`); } });