gettings started with npm and nodeks code example

Example 1: node js server

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))

Example 2: run node app locally

// Run this command in your terminal to start your node application.
// Replace the tag with your applications main file name (ex index.js, main.js etc). 
// Add alternative a relative or absolute path before the name.

node <filename>.js