Express JS

Install Express JS and generator

Use the following command to install express:

  • Express installation
    • npm install express
  • Express generator installation
    • npm install express-generator -g
  • Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
  • To test the installation use following command:
    • express –version

Screen Shot 2016-07-09 at 11.08.24 PMScreen Shot 2016-07-09 at 11.10.55 PM


Create an app

  • express [your-app]

Screen Shot 2016-07-09 at 11.20.00 PM.png

  • Install required node modules
    • npm install

Screen Shot 2016-07-09 at 11.38.36 PM

  • Start the application
    • npm start
  • Open browser and enter localhost:3000. You should see the following:

Screen Shot 2016-07-09 at 11.52.17 PM

npm install [node_modules]

Checking node and npm installation

Use the following command to test if npm & node is installed:

  • node –version or node -v
  • npm –version or npm -v

Refer to this POST in case node or npm is not installed.


Initializing a node project

  • npm init
  • This will initialize node programming on current folder and will create a package.json file. Package.json will contain the list of dependencies required for application development.

Installing node pakage using npm

Use the following command to install a node package:

  • npm install [package_name]
    • This will install the specified package into the local node_modules folder.
    • Ex: npm install bower
    • Parameters:
      • -g or –global: This installs the package as a global package.
        • Ex: npm install -g gulp
      • -S, –save: Package will appear in your dependencies.
        • Ex: npm install –save gulp
      • -D, –save-dev: Package will appear in your devDependencies.
        • Ex: npm install –save-dev gulp
      • -O, –save-optional: Package will appear in your optionalDependencies.
        • Ex: npm install -save-optional gulp
      • -E, –save-exact: Saved dependencies will be configured with an exact version rather than using npm’s default semver range operator.
  • npm install
    • This will install all modules listed as dependencies in package.json.

Gulpgulp-error

Use the following command to install gulp:

  • npm install -g gulp
  • Gulp is the streaming build system. It is recommended to install it globally as it can be required on multiple projects.

Bowerbower-logo

Use the following command to install gulp:

  • npm install -g bower
  • Bower is a package manager for the web. It is recommended to install it globally as it can be required on multiple projects.

express_jsExpress

Use the following command to install express:

  • npm install express
  • npm install express-generator -g
  • Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

Lodashlogo202

Use the following command to install lodash:

  • npm i –save lodash
  • A modern JavaScript utility library delivering modularity, performance, & extras. Lodash makes JavaScript easier by taking the hassle out of working with arrays,
    numbers, objects, strings, etc.

angularjs

Use the following command to install angularjs:

  • npm install angular
  • Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. It is recommended to install it locally as it is required on the production code.

Many more libraries can be added from NPMJS site.

Refer to npm-install page for more details.