Node.js error: getaddrinfo ENOTFOUND localhost

The error getaddrinfo ENOTFOUND localhost is caused by Webpack cannot found localhost address.
To solve it, open the terminal:
sudo nano /etc/hosts- Add following into the hosts file and save it.
127.0.0.1 localhost
References: