brew install hadoop installing 2.8.1 version. But needed 2.7.4 version

(@bfontaine its not a duplicate question as that answer is 6 years ago and no longer works)

You can try running

brew list --versions hadoop

to see if you have previous versions and you can switch to it by running

brew switch hadoop 2.7.4 

There is

brew install <package_name>@<version>

Unfortunately it seems hadoop and many other packages haven't set it up to be possible to download the older version and I haven't found out a way to do it.