I'm looking to set up automated builds with Visual Studio Team Services but I keep running into trouble. My build definition:
npm install gulp
npm install --save-dev jshint gulp-jshint ruby
npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
gem install sass
gulp
The build fails when attempting to install the sass gem with "'gem' is not recognized as an internal or external command". If I build without installing the sass gem first, gulp will fail with "'sass' is not recognized as an internal or external command". Anyone have experience with getting sass to work in Visual Studio Team Services?
There seem to be several issue here. First you might need to make you familiar how npm works, whats the meaning of
--save-devand whats the difference between local and globally installed modules.--save-devis used to save the package for development purpose, while--saveis used to save the package required for the application to run. Both are commands which you run on your development machine and you put the resultingpackage.jsonunder version control. On the build server you will just run annpm installwhich will restore all the packages listed in thepackage.json.These is for local modules. You can also install modules globally using the
-gflag. This will store them outside of your current project, and binaries will be available in yourPATHvariable. Modules which you need inside your project (usingrequire) need to be installed locally. Modules you'll call from the shell (eggulp-cli) need to be installed globally.Therefore what you need to do:
npm installwith either the--saveor--save-devflag.package.jsonfile under version control.npm installusing the VSTS npm task to restore the local npm modules. You won't need to specify which modules need to be installed, since they're already listed in thepackage.jsonfile.gulpusing the VSTS gulp task with the appropriate arguments.