bzw
bzw

Reputation: 253

Yeoman Generator: Installing project dependencies in custom folder

After generating my project scaffolding, I'd like Yeoman to install my npm dependencies in a subfolder, rather than in the main project folder. I have my package.json file in the /gulp subfolder of my project. How can I have Yeoman install the dependencies there? Here is my current function that runs at the end of the generator:

this.on('end', function () {
  if (!this.options['skip-install']) {
    this.installDependencies({
      bower: false,
      npm: true
    });
  }
});

Upvotes: 9

Views: 3710

Answers (1)

bzw
bzw

Reputation: 253

Finally got this working by changing the directory before running this.installDependencies() in index.js, as in:

this.on('end', function () {
  if (!this.options['skip-install']) {

    // Change working directory to 'gulp' for dependency install
    var npmdir = process.cwd() + '/gulp';
    process.chdir(npmdir);

    this.installDependencies({
      bower: false,
      npm: true
    });
  }
});

Hope this helps if you have a different project scaffolding setup.

Upvotes: 16

Related Questions