$ npm install hosts-path
Get the path to the hosts file
$ npm install --save hosts-path
var hostsPath = require('hosts-path'); hostsPath(); //=> '/etc/hosts'
MIT © Kevin Martensson