- Node.js ☛ is an event-driven non-blocking JavaScript middleware. Opponents are Spring, Django, Java Enterprise Edition (Java EE)… or Deno, Bun (written in Zig)… in the JavaScript/TypeScript ecosystem.
- Version:
node -v
- Capability:
node -h
- Execution:
node Main.js
- Node.js ☛ comes with a lot of native libraries like
fs
(file system),http
,path
…, but its ecosystem is rich of numerous external libraries whose consistent management relies on npm (Node.js ☛ package manager)- Program example (using Puppeteer ext. lib.) ☛
npm is in sync with a
package.json
file for configuration purposes including file location, nature, purpose… library versioning, licensing, etc.Library versioning
- Reminder on versioning: "4.17.1" ⤳ major: 4 (backward incompatible), minor: 17 (backward compatible), and patch: 1
- So
"express": "~4.17.1",
⤳ patches only, e.g., up to"4.17.3"
- So
"express": "^4.17.1",
⤳ up to non-breaking API, i.e., very latest minor version, e.g., up to"4.18.1"
"mongodb": "*",
⤳ upgrades to very last versionOther configurations
"engines": { "node": ">=10" },
⤳ fixes compatible Node.js ☛ version"scripts": { "start": "node js/Main.js" },
- Etc.
- Where is Node.js ☛ on macOS ⤳
which node
⤳/usr/local/bin/node
- Where is Node.js ☛ on Windows ⤳
Get-Command node
⤳C:\Program Files\nodejs\node.exe
- Update of Node.js ☛
- macOS (update Homebrew) ⤳
brew -v; brew upgrade
- macOS (install Node.js ☛ version manager, i.e., nvm) ⤳
brew reinstall --verbose nvm
- macOS (use nvm) ⤳
nvm -v nvm ls nvm ls-remote # -> 18.20.8 nvm install lts/hydrogen; node -v # -> v22.14.0 nvm install lts/jod; node -v nvm use lts/hydrogen; node -v
- Version check of npm:
npm -v
- Where is npm on macOS:
which npm
⤳/usr/local/bin/npm
- Where is npm on Windows:
Get-Command npm
⤳C:\Program Files\nodejs\npm.cmd
- Update:
<sudo> npm install npm@latest
- Where are installed modules?
npm root -g
(-g
means “global”)- What are global installed modules?
npm list -g -depth=0
- Installation of library from a directory having a
package.json
file, example:<sudo> npm install ./lib/tracking.js-master
- Programming Node.js ☛ with TypeScript ☛
- Blocking versus non-blocking ☛
- Node.js ☛ module system ☛
- Environment variables within Node.js ☛ ☛
- Programming Web server with Node.js ☛ ☛
- Querying the Web with Node.js ☛ ☛
- Database tiers with Node.js ☛ ⤳ SQL ☛
- Database tiers with Node.js ☛ ⤳ NoSQL ☛
- Micro-services with Node.js ☛ ☛
- Messaging with Node.js ☛ ☛
- Authentification ☛
- Orchestration ☛
- Web streams ☛
- Clustering and worker TO DO ☛
- WebAssembly ☛
*Tout ou partie des mécanismes énoncés peuvent (probablement) répondre au besoin. Toutefois, il faut choisir (cocher) le mécanisme le plus simple, direct et rationnel qui amène à produire le moins de code possible au regard du besoin évoqué.
- Internet of Things -IoT-: Node-RED