- 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.) ☛
Node.js Version Manager -nvm- is used to install Node.js
macOS
brew -v; brew upgrade # update Homebrew brew reinstall --verbose nvm
nvm -v nvm ls nvm ls-remote nvm install lts/hydrogen # -> 18.20.8 nvm install lts/jod # -> v22.14.0 nvm use lts/hydrogen; node -v
Where is Node.js ☛ on macOS ⤳
which node
⤳ e.g.,/usr/local/bin/node
Windows
# Admin. choco upgrade chocolatey choco --version choco upgrade nvm choco list
nvm -v nvm list # locally installed ver. nvm list available # remotely downloadable ver. nvm install hydrogen # -> ver. 18.20.8 nvm use hydrogen nvm current # <=> 'node -v'
Where is Node.js ☛ on Windows ⤳
Get-Command node
⤳ e.g.,C:\nvm4w\nodejs\node.exe
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.
- 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
Version npm compatible avec Node.js 18
- 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