diff --git a/lib/template.js b/lib/template.js index c7005d8..a28a5e1 100644 --- a/lib/template.js +++ b/lib/template.js @@ -283,7 +283,10 @@ function createTargetDirectory (target) { } function installDependenciesIfPresent () { - if (!fs.existsSync(path.join(this.path, 'package.json'))) { return } + const pkgPath = path.join(this.path, 'package.json') + if (!fs.existsSync(pkgPath)) { return } + const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) + if (!pkg.dependencies) { return } this.sprout.emit('msg', 'installing npm dependencies') return exec('npm install --production', { cwd: this.path }) }