Advance Javascript

  1. NPM

    npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you're sharing. In order to install npm, you need to install node.js first. Run following command

     
    node -v
    Run node -v. The version should be higher than v0.10.32.

    Node comes with npm installed so you should have a version of npm. However, npm gets updated more frequently than Node does, so you'll want to make sure it's the latest version.

     
    sudo npm install npm -g.

    Test: Run npm -v. The version should be higher than 2.1.8.

  2. Grunt

    Grunt is a java script task runner, it will help you on running various task like minification, compilation, unit testing, linting, etc. Grunt and Grunt plugins are installed and managed via npm. To start, you need to install Grunt's command line interface (CLI) globally.

     
    	sudo npm install -g grunt-cli

    This will put the grunt command in your system path, allowing it to be run from any directory.

    A typical setup will involve adding two files to your project: package.json and the Gruntfile.

    package.json: This file is used by npm to store metadata for projects published as npm modules. You will list grunt and the Grunt plugins your project needs as devDependencies in this file.

    Gruntfile: This file is named Gruntfile.js or Gruntfile.coffee and is used to configure or define tasks and load Grunt plugins. When this documentation mentions a Gruntfile it is talking about a file, which is either a Gruntfile.js or a Gruntfile.coffee.

     
    	npm init 

    Run this command on root directory of your project to create package.json.

    To install grunt to your project directory you just need to run:
     
    npm install grunt --save-dev
     
    grunt

    Run this command to execute your javascript task on project.

  3. Bower

    Bower is a package manager for web. Web sites are made of lots of things — frameworks, libraries, assets, utilities, and rainbows. Bower manages all these things for you. You can install bower with this command.
     
    sudo npm install -g bower
    You can install any register package with this
     
    bower install jquery
    bower install git://github.com/user/package.git
    bower install http://example.com/script.js
    Use this to initialize bower on your project.
     
    bower init
  4. grunt-bower

    Copy bower installed components to dist folder. Install grunt bower with this
     
    npm install grunt-bower
    Then add this line to your project's grunt.js gruntfile:
     
    grunt.loadNpmTasks('grunt-bower');