Node.js Basics
Node.js Installation and Setup
Install Node.js from nodejs.org or, better, through a version manager such as nvm so you can switch versions per project. Installing Node also installs npm, its package manager.
What is Installation and Setup in Node.js?
Install Node.js from nodejs.org or, better, through a version manager such as nvm so you can switch versions per project. Installing Node also installs npm, its package manager.
Installation and Setup example
Terminal
# macOS / Linux — version manager (recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
nvm install --lts
nvm use --lts
# verify
node -v # v22.x.x
npm -v # 10.x.xRun your first script
Terminal
echo "console.log('Node is working')" > app.js
node app.js
node --watch app.js # restarts automatically on saveKey points to remember
- Prefer an LTS release for anything real — odd-numbered versions are short-lived.
- nvm (or nvm-windows, or fnm) lets different projects use different Node versions.
- The built-in --watch flag removes the need for nodemon in most cases.
- node with no arguments opens a REPL for quick experiments.
Common mistakes with Installation and Setup
- Installing Node with sudo, which creates permission problems with global npm packages later.
- Running a project on a Node version older than its engines field requires.
Node.js Installation and Setup— Interview Questions & FAQs
Which Node.js version should I install?+
The current LTS release. LTS versions get around three years of support and are what hosting providers and most libraries target.
