Gulp

  • Task manager for web project.
  • npm install -g gulp or npm install gulp –save-dev [for devDependencies, gulp is not needed for deployment]
  • Make gulpfile.js run gulp style, gives warning according to the code.
  • To inject js and css automatically:
    • npm install wiredep –save-dev #for bower dependencies
    • npm install gulp-inject –save-dev #for our dependencies
    • Code in gulpFile.js for injecting file.
    • in HTML files put
      <!– bower: js–>
      <!– endbower –>
    • for inject put
      <!– inject: js–>
      <!– endinject –>
    • run gulp inject and HTML files would have all js files required.
    • [See memo for css/less problem in bootstrap/gulp]

//These tools are used in gulpFile.js

JS Hint:

  • For coding standards => .jshintrc
  • Configurable and open source

JSCS:

  • For coding style => .jscsrc
  • Configurable and open source

ExpressJs

use express.static to serve a folder, nodejs will check in this folder to render
    app.use(express.static(“<folderPath>”))

  • app.get(“/text”, function(request, response){..});
  • app.post(“/text”, function(request, response){…});
  • var router = require(“express”).Router();
    router.route(“/”)
    .get(function(req, res){…});
    app.use(“/text”,
    router);
    /text/ app will use router, for /text/text2/, router.route(“/text2”, …) can be used.
  • app.get(“/:id”)

Bower

  • A front-end package management tool.
  • Flat package hierarchy.
  • bower.json
  • npm install bower -g
  • bower init
  • bower install <packageName> –save
  • Make .bowerrc file, add “directory”: “<fullPathoftheFolder>”; bower install…

Nodejs, Express and NPM Introduction

NODEJS:
https://nodejs.org/

Nodejs is an open-source, server-side, running environment.

  • Cross platform
  • Uses JS as language

EXPRESS:
http://expressjs.com/

Web developement framework for nodejs.

NPM:

Node Package Manager.

  • Easy update and version management.
  • npm init => make package.json
  • npm install <package-name> –save => saves the package to package.json
    When saving a package to package.json there can be these string formats:
    “^4.x.x”  [Any release 4 major or minor version]
    “~4.13.x”  [Any minor version of 4.13]
    “4.13.2”  [Exact version]
    “*”  [Newest]
  • in  package.json, in scripts object write “start”: “node index.js”, in console write npm start. The start object would get run.