How to safely install drywall anchors near wiring
Position the rack so you can screw into the studs. If that is not practical then mount a sheet of decent thickness plywood onto the wall surface and fasten that to the studs wherever possible. The rack can then mount onto the plywood. If you use a plywood that is 3/4' inch (19 or 20mm) thick then the screws for the rack need not even penetrate the drywall at all.

BTW. It is generally (if not always) discouraged to mount anything that will carry significant weight just on drywall anchors.