If you want to hang a light fixture in a location where there is no electrical box, it is tempting to simply make a hole in the drywall for the wire and affix the fixture to the wall with plastic screw anchors. This is not very effective because anchors tend to work themselves out of the wall over time, and it is not necessary, either. You can easily install an "old work" or "remodel" junction box that anchors itself to the drywall, giving you a safe and secure place to attach your fixture.
Turn off the electricity to the circuit before you begin.
Draw the outline of the back of the junction box on the drywall where you plan to install the fixture. Cut out the opening with a drywall saw.
Punch out a hole in the back of the box and feed the electrical wire through.
Place the junction box into the hole, and twist the locking screws until the plastic anchors behind the box are seated behind the drywall. Pull the box a little so that the anchors offer resistance. Tighten the screws until the box is firmly attached.
Remove about 6 inches of sheathing from the electrical wire with a utility knife. Separate the wires and use the splicing tool to remove about one-half inch of the plastic coating from the black and white wires.
Hold the white wires from the electrical cable and the fixture together and twist them clockwise with pliers. Then screw on a wire nut. Repeat with the black wires.
Twist the ground wires together.
Screw the adapter that came with the fixture onto the junction box. Stuff the wires into the box and affix the fixture to the adapter with the screws provided.
Turn on the electricity and test the light.