Node.js - Overview
$ node > var a = 1; undefined > a + 1 2
Node doesn’t run any of your application code in parallel
- event-driven, non-blocking I/O, fast and lightweight.
- npm, the package manager.
- awesome libraries.
- not supporting multi-threading.
- not suitable for heavy computing problems.
- no strict checking, could result in runtime problems.
Data-driven, I/O-driven, event-driven, and non-blocking applications benefit the best from a Node.js implementation.
- Data-intensive programs are focus on retrieving and storing data,
- I/O-intensive programs focus on interacting with external resources.
Web servers are a perfect use case that benefits from Node’s inherent features.
Node a bad choice for CPU-intensive programs.
Check version of node:
$ node -v vX.X.X
Check version of npm:
$ npm -v X.X.X
nodemon will watch the files in the directory in which nodemon was started, and if any files change, nodemon will automatically restart your node application.
$ sudo npm install -g nodemon
$ sudo npm install -g pm2
Start production, with max memory:
$ NODE_ENV=production pm2 -f start app.js --max-memory-restart 200M
$ pm2 monit