TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸

Node.js Basics

April 13, 2015

Was ist Node.js?

Node.js ist eine JavaScript Runtime fuer Server und CLI. Sie ist event-basiert und non-blocking, also gut fuer I/O (Dateien, Netzwerk).

Erste Schritte

Version pruefen:

code
node -v

Datei ausfuehren:

code
node app.js

REPL

code
node

Beenden: Ctrl+C zweimal.

Hello World

code
console.log("Hallo Welt");

Module System

  • CommonJS: require(...)
  • ESM: import ... from ... (wenn "type": "module" in package.json)

Kleines Beispiel: JSON von API

code
import fetch from "node-fetch";

const res = await fetch("https://api.example.com/data");
const data = await res.json();
console.log(data);

npm

code
npm init -y
npm i node-fetch