Wednesday, July 15, 2015

Got just 1 Minute to Get Started Quickly with NPM?


  • Install nodejs from http://nodejs.org/
  • Install less to compile use less and compile it into a CSS file. Command:
    npm install -g less
  • Command to compile .less files into .css:
    lessc styles.less > styles.css
  • Create a package.json file. Go the project root folder and run command:
    npm init
    Answer the questions it asks or just use the default options to get started. This json file is used to store information about frameworks, their versions, etc. used in the project in current folder. This is also used by Grunt and Gulp for automation.
  • Install required packages to use in the project. You have three ways to install packages.
    • Install in the current project folder without using any options.
    • Install globally using -g or -global option.
      npm install -g cordova
    • Create devDependencies section / property inside the package.json file. Use option:
      --save-dev
Example package.json:
{
  "name": "grvgl",
  "version": "0.0.0",
  "description": "sample",
  "main": "app/index.html",
  "scripts": {
    "test": "test"
  },
  "author": "",
  "license": "ISC"
}

No comments: