Naphthalene, the active ingredient in most mothballs, does a poor job of repelling squirrels and other animals. Additionally, the Environmental Protection Agency regulates products containing naphthalene as pesticides and forbids their use in ways not specified by the product label. Mothballs' labels usually recommend use only in tightly sealed containers.
For natural control of squirrels, cayenne pepper, red pepper and chili powder top gardening lists. These spices contain capsaicin, which causes a "hot" taste and watery eyes and nose on ingestion. Unlike some humans, squirrels don't enjoy these sensations, so sprinkling the spices liberally around the areas to be protected discourages the animals from remaining around those places and doesn't harm plants. Birds are unaffected by capsaicin, so mixing the spices with seed also discourages squirrels from raiding bird feeders. The drawbacks to capsaicin-containing spices are the need for frequent reapplication and the potential for harming beneficial insects, such as ladybugs and honeybees.