prune: check package.json before running

Fixes #3755.