Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
    });
  }
});
like image 748
bzw Avatar asked Mar 12 '14 19:03

bzw


1 Answers

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.

like image 73
bzw Avatar answered Nov 13 '22 13:11

bzw