I read other questions like this here but none solved my issue. I have a terminal window on which I ran
geth --networkid=4 --rpc --rpcport 8545 --datadir=$HOME/.rinkeby --syncmode=light --ethstats='yournode:Respect my email@example.com' --bootnodes=enode://firstname.lastname@example.org:30303?discport=30304
based on the connect yourself section of the test chain Rinkeby.
I also have a node app which has
var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
and which I'm running after launching geth.
The terminal launches geth with no issues and outputs
INFO [07-12|15:40:40] HTTP endpoint opened: http://127.0.0.1:8545. I don't understand why my node app is having trouble connecting to it.
The error is
ReferenceError: web3 is not defined.