Your connection is working. To return an array of the accounts use web3.eth.getAccounts() rather than web3.eth.accounts.
The code above should look something like this:-
Web3 = require('web3')
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); web3.eth.getAccounts().then(accounts => console.log(accounts));
Which will give you something such as:-
[ '0x09e67e758381Fb878b9B1dCB91f2D5a62E00035a', '0x1BaABCa410a88564aC2BD9b8570D21b6e898C4C3', '0x8bfF74332C52065d2CC46f96c191aCDeec1AFEF2', '0x19070EaC7D68a710A5843Ee8cA3de258024da3Cb', '0x909394eA6feA0aDba05f093Ae43782e42b462F56', '0x63527Ef51b17830d6F597686C366A1995fd31bb2', '0xf476D31fAD8605d9D9D7b557C5117Bbe102935bc', '0xA64ba4e9d332106181A073E6eD20F876D6e28856', '0x126533F5FC78E355Fc35476Ae1392D338366D229', '0x291c17c0901FC9143D0DC43E1455E20D26342377' ]