KarmaGenerator() already attempts to do this at line 30, but it does nothing if package.json doesn't already exist. So looks like you just need provide a stub package.json for it. It also wrongly uses the save option instead of save-dev, so you'll want to change that while you're at it.