Web3.js not connecting infure

Belwo is my code to execute a simple Jsp pgm having web3.js

let web3 = require('web3');
const tr = new web3(web3.givenProvider || "http://localhost:8545");
async function discuss()
   const latest = await tr.eth.getBlock(1);

Before doing this , I have run command to install web3 which is npm i web3 . However I am not getting any result. Instead the error shown is :-

You obviously need to run on your local machine, an EVM process (for example, Ganache), listening on port 8545.