Node.js Setup & Cloudflare Deployment
Install Node.js and deploy your first project to Cloudflare Pages.
01 Install Node.js
Node.js is a JavaScript runtime that lets you run JS outside the browser. You need it for npm, build tools, and more.
- Go to nodejs.org
- Download the LTS version (the green button)
- Run the installer — accept all defaults, no changes needed
- Restart your terminal after installation
Verify it worked:
$ node --version
v22.x.x
$ npm --version
10.x.x
If you see version numbers, Node.js is installed correctly.
02 Deploy to Cloudflare Pages
Once your project works locally, deploy it for free on Cloudflare Pages. You get a live URL, HTTPS, and a global CDN — all on the free tier.
Method A — Direct Upload (quickest)
No GitHub needed. Just build your project and drag the folder to Cloudflare.
- Build your project:
npm run build - Find the output folder — usually called
distorbuild - Go to dash.cloudflare.com
- Navigate to Workers & Pages → Create application → Pages
- Click Upload assets
- Name your project and click Create project
- Drag your
distfolder into the upload area - Click Deploy — done! You get a
your-project.pages.devURL
Every time you make changes, just run npm run build again and re-upload the dist folder.
Method B — Git Integration (auto-deploy)
Push to GitHub and Cloudflare auto-deploys on every commit. More setup, but better long-term.
Push to GitHub first:
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/YOU/repo.git
$ git push -u origin main
Then on Cloudflare:
- Go to dash.cloudflare.com
- Navigate to Workers & Pages → Create application → Pages → Connect to Git
- Select your GitHub repo
- Set build command:
npm run build, output directory:dist - Click Save and Deploy
Now every git push automatically redeploys your site.
Summary
- 01 Installed Node.js — the JavaScript runtime
- 02 Deployed a project to Cloudflare Pages