Cannot install brew in Mojave 10.14.5, user name is not in the sudoers file

The terminal always says "UserName is not in the sudoers file. This incident will be reported. "
What’s more, I can not use command sudo, period. Also, I cannot modify sudoers file. The file doesn’t seem to exist any more. How can I install Homebrew without reversing to older macOS?

I’m a bit surprised by this, assuming that this is a personal computer. Does anyone know if Apple messed with sip or user account defaults in 10.14.5?

Is this mac your personal computer or is a shared machine at, e.g., a university or company?

Homebrew (on macOS) more-or-less assumes that the computer is a personal computer and the user has administrative privileges. Your account, it would appear, does not have such privileges.

To enable sudo you (or someone else who already has administrative privileges) will have to go to the macOS settings menu and modify your account:

System Preferences --> Users & Groups --> Select your username on the left --> Tick the checkbox that reads “Allow user to administer this computer”. You may need to click the pad-lock icon in the lower left to unlock and allow changes. If that’s the case, you may need to get another user who is an administrator to do this for you.

If you are on a shared university or corporate computer, there may be policies to prevent users from putting stuff in /usr/local. In that case, you could try installing it into your home folder, but this is not recommended, as some stuff may break, and some formulae will need to be built from source because they are not relocatable. If you decide to go this route, see: