Why does fs.link() fail with EPERM whre fs.rename() succeeds?

I want to serve some static files under the directory /var/www I would like to swap in a new set of files (which exist as, for example, /var/data/example) every few days or so. The server does not follow symlinks (the host is Linux).

So the curious thing is that when I try a hardlink I get an EPERM:

fs.link('/var/data/example', '/var/www');

This is a bit surprising, since I can create /var/www. What’s more if I do this:

fs.rename(`/var/data/example', '/var/www')

it works! I am mystified by this. I would rather use links, as it allows me to preserve what used to be there, rather than clobbering it.

Does anyone know why this might be happening?