Getting Started with JavaScript and Node.js
JavaScript runs in the browser and, via Node.js, on the server. This guide installs Node.js and runs your first script.
1. Install Node.js (LTS) via NodeSource
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs2. Verify the install
node --version
npm --version3. Write your first script
echo 'console.log("Hello from Node.js");' > app.js
node app.js4. Core JavaScript concepts
- Variables:
let,const, and (legacy)var - Functions:
const add = (a, b) => a + b; - Arrays & objects:
[1,2,3]and{ name: "Cloudesta" } - Async:
async/awaitand Promises for non-blocking code
Start a new project with npm init -y and add packages with npm install <package>.