Node.js Overview
- Node is optimized for I/O-heavy workloads, not compute-heavy operations
- Node provides a non-blocking, event-driven architecture. The non-blocking model enables concurrency without managing threads manually.
- Node is interface to V8. V8 runs the code Node provides the environment
- Node scripts run with unrestricted access to system resources. New permission model exists, it is disabled by default
Packages
- A module is a single file that contains JavaScript code.
- A package is a directory containing modules and a
package.json
file.
- file provides metadata about the package, such as its name, version, and dependencies.
- package manager : automates managing packages
package-lock.json
records exact version of each installed package & dependencies .It helps to build identical dependency tree in every dEV environment.
node -c your_script.js #syntax check
node -p "crypto.randomBytes(16).toString('hex')"
node -p "process.argv" hello world #[<path/to/node.js>, 'hello', 'world']
node --watch index.js
node --v8-options | less
node --env-file=.env script.js
node --run start
Core Functionality & System Interaction
node:buffer
: Handles binary data.
node:child_process
: Runs shell commands or forks processes.
node:cluster
: Provides load balancing across workers.
node:crypto
: Offers cryptographic operations.