Node
Node
Node takes the JS complier in chrome browser and adds some server logic and io stuff so you can use it on the backend. So node filename
lets you run arbitrary js logic where console.log is std.out
JS is a language
Assert
Versions
Even numbered releases are LongTerm Support(LTS); they generally receive 30 months of support once they become LTS. Given codename
V20 is iron and ends support in April 2026
V18 is hydrogen and ends support in April 2025
Odd numbered releases are current releases and are supported for six months.
Express(4.16)
Most Basic Code
Can run with node [filename]
Overview
Middleware have access to request object (req), response object (res), and the next middleware ft(next). If you don't respond with res, call next()
Run for every request
Run for specific urls
Types
app.use(...)
=> for any HTTP requestapp.get(...)
=> for get request
Globals
__dirname
=> full from root name of the directory that the executing script resides fromprocess.env
=> environment at start of runtime can use to access PATH and other env variables likeprocess.env.NODE_ENV
export NODE_ENV=production
while running to run in production mode, many libs check for it including express which will not print out stack traces and config
Last updated