# Node.js Notes

**Installation Commands**

```
$ brew update // get latest version of brew
$ brew install node
$ node -v // check if it is done
```

**NPM Commands**

```
$ npm -v
$ npm init // to generate package.json file
$ npm install ${package} --save // Using 'save' option to add dependency into package.json
$ npm install yargs@4.7.1 --save // @ is for version specified.
$ npm install // follow package.json to install all dependencies
$ npm i express@4.14.0 --save
$ npm i socket.io@1.4.8 --save
$ npm i expect@1.20.2 mocha@3.0.2 --save-dev
$ npm i nodemon@1.10.2 --save-dev // install at local and use it instead of global one
$ npm uninstall ${package}
```

**Utility & Framework**

* axios (Promise based HTTP client)
* expect (For assertion)
* express (Web framework)
* mocha (Test framework)
* lodash (useful functions)
* request (HTTP client)
* socket.io (Real time application)
* yargs (CLI module)

**Tools**

* Nodemon (command line utility for hot deployment)

  ```
  $ npm install nodemon -g // global, can execute command from command line.
  ```

**Debugging**

* Executing in debug mode

  ```
  $ node inspect ${file}
  ```
* Actions under debug mode:
  * list(${number}) // lines to display
  * n // next
  * c // continue
  * repl // switch to replacement mode
* syntax to halt debugging:

  ```
  debugger;
  ```
