prune: check package.json before running

Fixes #3755.
update/outdated: don't access missing package info
avoid null derefernces checking the status of a
currently installed package

Fixes #3820, a regression caused by #3798 and #3578