The Front-End Toolchain: Git, npm and Build Tools
Move from single files to real projects: the terminal basics, Git and GitHub, Node and npm, package.json and lock files, bundlers such as Vite, linting and formatting, environment variables, testing and deployment. A map of the tools and the workflow professional teams use.
1. From a file to a project
So far your pages have been one HTML file with some CSS and JavaScript. Real front-end projects have dozens or hundreds of files, use libraries written by other people, are worked on by teams, and are built and deployed automatically. A small set of tools makes that possible. This lesson is the map; you will learn each one in depth through use.
| Need | Tool |
|---|---|
| Run commands | The terminal (command line) |
| Track and share changes | Git and a host (GitHub, GitLab) |
| Run JavaScript outside the browser and manage libraries | Node.js and npm |
| Compile, bundle and serve | Vite (or webpack, esbuild, Parcel) |
| Catch mistakes and keep style consistent | ESLint, Prettier, TypeScript |
| Check it works | Vitest/Jest, Playwright, Testing Library |
| Put it online | Vercel, Netlify, Cloudflare Pages, GitHub Pages |
2. The terminal in five minutes
pwd # where am I?
ls # what is here? (Windows PowerShell also accepts ls and dir)
cd my-project # go into a folder (cd .. goes up)
mkdir src # make a folder
node --version # is Node installed?
Press Tab to complete names, Up to repeat commands, and Ctrl+C to stop a running process. Learn more in the Linux course.
3. Git: your project’s history
Git records snapshots of your project so you can see what changed, undo mistakes, work on features in parallel and collaborate. GitHub (or GitLab, Bitbucket) hosts a shared copy.
git init # start tracking this folder
git status # what changed?
git add . # stage everything for the next snapshot
git commit -m "Add navigation" # save the snapshot with a message
git log --oneline # history
git switch -c feature/footer # a new branch for a new piece of work
git push -u origin feature/footer # publish your branch
Habits: commit small, focused changes with messages that say why; work on a branch and open a pull request for review; pull before you push; and never commit secrets (API keys, passwords, .env files). Add a .gitignore for node_modules, build output and local files. The Network Automation course has a deeper Git lesson.
4. Node and npm
Node.js runs JavaScript on your computer, which build tools need. npm (Node Package Manager) installs and manages packages, the libraries and tools in the world’s largest software registry.
npm create vite@latest my-app # scaffold a new project from a template
cd my-app
npm install # install the dependencies listed in package.json
npm run dev # start the dev server (scripts come from package.json)
npm run build # make the production files
npm install dayjs # add a library (recorded in package.json)
npm install -D eslint # add a dev-only tool
package.json and the lock file
package.json describes the project: its name, its scripts, and its dependencies (what the app needs at runtime) and devDependencies (tools for building and testing). Versions use ranges: ^4.2.1 allows compatible updates.
package-lock.json records the exact versions installed. Commit it, and use npm ci in automated builds so everyone gets identical dependencies.
Never commit node_modules. It is large, generated and recreated by npm install.
Choosing packages carefully
Every dependency is code you ship and trust. Prefer well-maintained, widely used packages; check the download counts, last update and open security issues; watch for look-alike names; keep a small dependency tree; and run npm audit and keep dependencies updated. Sometimes the platform already does what a package does.
5. Build tools: Vite
Browsers can run ES modules directly, but production sites need much more: combining and minifying files, compiling TypeScript, JSX or Svelte/Vue components, optimising images and CSS, splitting code, and adding hashes to file names for caching. A build tool does it.
Vite is the most popular modern choice: a very fast dev server with hot module replacement (your edits appear instantly without a reload) and an optimised production build.
my-app/
index.html entry point
package.json
vite.config.js
src/
main.js entry script
components/
styles/
public/ copied as-is (favicon, robots.txt)
dist/ the build output (generated; do not commit)
Meta-frameworks (Next.js, Nuxt, SvelteKit, Astro, Remix) build on this and add routing, server rendering and deployment adapters.
6. Quality tools
- Prettier formats code automatically, ending style arguments.
- ESLint finds bugs and bad patterns (unused variables, missing dependencies, accessibility mistakes with the right plugin).
- TypeScript adds types to JavaScript, catching whole categories of mistakes in your editor before you run anything. It is the standard in professional teams.
- Editor: VS Code with its extensions for the above, plus an HTML/CSS/JS formatter and the language server for your framework.
- Git hooks (Husky, lint-staged) run these checks before each commit.
7. Configuration and environment variables
Configuration that differs between environments (an API address for development vs production) goes in environment variables, stored in .env files and read by the build tool:
VITE_API_URL=https://api.example.com
const api = import.meta.env.VITE_API_URL;
Anything that goes into the browser bundle is public. Variables that Vite (prefix VITE_), Next.js (NEXT_PUBLIC_) or Astro (PUBLIC_) expose to the client can be read by every visitor. Never put secrets there. Keep secrets on a server, and keep .env out of Git (commit a .env.example with names only).
8. Testing
- Unit tests (Vitest or Jest) check functions in isolation: formatting a price, validating input.
- Component tests (Testing Library) check that a component shows the right thing and responds to clicks, written the way a user would interact, by role and text rather than by implementation details.
- End-to-end tests (Playwright or Cypress) drive a real browser through the main journeys: sign up, search, check out. Keep them few and valuable.
- Automated accessibility checks (axe) catch common mistakes.
Run them in continuous integration so a pull request cannot be merged when tests fail.
9. Deploying
A built front end is just static files, so hosting is cheap and simple:
- Push your code to GitHub.
- Connect the repository to Vercel, Netlify, Cloudflare Pages or GitHub Pages.
- Set the build command (
npm run build) and output directory (dist). - Add environment variables in the host’s settings (not in Git).
- Every push to
maindeploys to production; every pull request gets a preview URL. - Add a custom domain, make sure HTTPS is on, and check redirects and the 404 page.
Check the deployed site, not only your machine: test on a phone, run Lighthouse on the live URL, and watch for errors with a monitoring tool.
10. A typical workflow
git switch -c feature/searchnpm run dev, edit code, and watch the browser update.- Write or update tests; run lint and tests locally.
git add,git commit,git push, open a pull request.- CI runs lint, tests and a build; a teammate reviews; a preview deploy lets everyone try it.
- Merge to
main; the site deploys automatically.
11. What you learned
You have a map of the professional toolchain: terminal, Git, Node and npm, package.json and lock files, Vite, linting, formatting, types, tests and automatic deploys. You know what to commit and what to ignore, why front-end environment variables are public, and how a change travels from your editor to production. Next, in the capstone, you will combine HTML, CSS and JavaScript into one finished interface.
🧪 Want to practise this on your own computer? See how to set up your lab →