10/13/2018

NPM

GULP!

Assignment 3

NPM

Node Package Manager

You can search for packages at npmjs.com

What is NPM?

What can you do with NPM?

Getting started with NPM

  1. Download and install node.js from nodejs.org
  2. Open your command line and type npm -v to verify everything installed properly
  3. Initialize your project by typing npm init while in your project directory
  4. Press enter a couple hundred times
  5. Verify that a package.json was created.

We can now get started downloading packages.

Let's look at a couple of commands.

  • npm install [package_name] to install a package
  • npm install [package_name] --save-dev to install a package and save it to your package.json
  • npm install [package_name] -g to install a package globally.
    • npm install gulp-cli -g installs gulp-cli globally and I can use gulp in the command line

node_modules folder

NPM creates a node_modules folder whenever you run npm install. Do not include and commit this folder to github.

Don't become too dependant on NPM

Gulp Task Runner

Let's automate all the hard stuff!

Gulpjs.com

What kind of stuff can we automate?

  • Asset Compression/Optimization
  • Code Validation
  • Unit Test
  • Deployments
  • Much more

Getting setup


    npm install gulp-cli -g
    npm install gulp --save-dev
        

Install your required packages

Create your gulpfile.js


        var gulp = require('gulp');

        //Tasks executes when you type `gulp` in the console
        gulp.task('default', function(){
            console.log('task');
        });

         //Tasks executes when you type `gulp css` in the console
        gulp.task('css', function(){
            console.log('task');
        });
        
        

Assignment 3

>