Wait for packages to install successfully before writing component.json ...

This keeps typos at the command line from getting written into `component.json`. Should fix #386.