Generalize npm handling and package.json generation