Web3.js integration

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 :-

Hi @Brijesh

The error says it cannot access http://localhost:8545 server port.
Do you have an active ethereum node running at http://localhost:8545 port ?