Alternatively, your Mac can delete the macOS installer on its own if it determines that your hard drive doesn’t have enough free space.
If you only want to delete the installer, you can select it from the Trash, then right-click the icon to reveal the Delete Immediately… option for just that file. How do I uninstall macOS High Sierra install?