The reason for the error is this line in my sudoers file (check yours with `visudo`):
# I can use pacman with sudo and don't have to enter a password
me ALL=NOPASSWD:/usr/bin/pacman
This line didn't seem to agree with packer; removing it made the installation work.