In this page of the Valheim game guide, you will learn how to prevent animals and enemies from spawning within your village's borders. This will prove extremely useful, especially if you have built your base one of the more dangerous regions. At the present time, there is no 100% guaranteed solution to this issue. Nevertheless, we have listed below the methods that have been the most effective in our experience.
One of the most effective ways (and also the most accessible) is to construct enough workbenches to cover the entire area of the village you want to protect. Although there have been some instances of deer, boars, or basic enemies spawning from time to time, using this method severely limited these occurrences.
You can use forges instead of workbenches, but the latter option is better as it requires much fewer resources to build.
A ward is a special structure that, among other things, prevents doors and chests from being opened by players who haven't originally crafted them or haven't been authorised by the ward while it was inactive (by pressing the "E" key).
In addition, when activated, it will emit a particular sound whenever any building within the range of its protective field is damaged. Most importantly, the ward has a much larger area of effect than the workbench and, similarly to workshops, appears to stop enemies from spawning within its range.
However, this solution is a lot more pricey, as you will need resources such as the extremely valuable and rare Surtling cores to craft it. The ward doesn't have to be activated to block enemies from spawning, making it easier to play with a larger group of people without the need to manage their permissions.
Leveling the ground with a hoe
The next solution sounds rather absurd, because it involves leveling the ground with a hoe. As it turns out, when you level the ground with a hoe, not only does it remove all the grass, but the area seems to "remember" that it has been modified in some way by the player.
Thus, when you modify an area in this manner, the spawn rate of enemies is noticeably decreased. If you dislike the appearance of bare soil, you can replant the grass with a cultivator, which won't prevent this method from working.
What does NOT work
In addition to the fact that the above methods have high but not 100% effectiveness, we can confirm that standing torches and similar items (e.g. sconces) do NOT stop enemies from spawning near them. The fire will scare away certain creatures (e.g. boars), but cause others to become more aggressive (e.g. Greydwarf shamans).
Some say that the bonfire can also prevent the spawning of enemies, but we have been unable to confirm the effectiveness of this method.