Recommended resources
The freely available resources this lesson will direct you to.
Welcome back! In our previous lesson, you learned about Vercel and why it’s such a powerful and popular choice for deploying web applications. We covered how it simplifies the process of getting your code from your computer onto the live internet, making it a perfect partner for the "vibe coding" workflow.
Today, we’re going to focus on a crucial step that happens just before deployment: the build process. You've likely seen your LLM assistant instruct you to run a command like npm run build. This lesson will demystify what that command does, why it’s necessary, and how to identify the result—the package of files that's ready for the world.
From Blueprint to Final Product: The "Build" Step
Think about your work in industrial design or with 3D printing. You create a detailed, complex model in a CAD program. This file is your source of truth—it's well-organized, editable, and makes sense to you. But a 3D printer can't use that CAD file directly. It needs G-code: a highly optimized, simplified set of instructions that tells the printer exactly where to move, layer by layer.
The process of "slicing" your CAD model into G-code is a perfect analogy for the build process in web development.
- Your
srcfolder: This is your CAD file. It contains your source code, neatly organized into components, pages, and styles. It's written for humans (and AI assistants) to read and edit. - The
buildcommand: This is your slicer software. It takes your source code and transforms it into a format that's optimized for the end user's environment—in this case, a web browser. - The
buildordistfolder: This is your G-code. It contains the final, optimized files that will be deployed to a server. You never edit this folder directly, just as you wouldn't edit the G-code by hand.
The code you work with during development is not what users' browsers actually receive. The build process is the essential bridge between the two.
What Happens When You Run npm run build?
So what is this "slicing" process actually doing to your code? The npm run build command triggers a series of automated tasks that prepare your project for production. It’s not just copying files; it's a sophisticated transformation.
Let's look at what's happening under the hood.
Discussing the npm run build command
This article explains the core reason why a build step is necessary in modern web development.
Read the section titled The Complexity of Browsers/Node.js. It highlights a key problem: the "fragmentation" of JavaScript. Different browsers support different features, and the build process, often using tools like Babel, ensures your modern code is converted into a compatible version that runs everywhere.
As the article explains, the build process solves the problem of browser compatibility. But it also does much more to optimize your app. Here are the main jobs it performs:
- Transpiling: It converts modern JavaScript, TypeScript, or framework-specific syntax (like the HTML-in-JavaScript you see in React, called JSX) into standard, backwards-compatible JavaScript that virtually all browsers can understand.
- Bundling: Your project is made of dozens or even hundreds of separate files for organization. The build process "bundles" them together, combining many JavaScript files into one or a few, and doing the same for CSS. This is far more efficient, as the browser needs to make fewer requests to load your site.
- Minification: It removes all unnecessary characters from your code—spaces, line breaks, comments, etc.—and shortens variable names. This makes the files dramatically smaller, leading to faster download times for the user.
This process is fundamentally different from the npm run dev command you use for local development.
How npm run dev Updates Your Site Instantly (and How It Differs from Build) - DEV Community
This article provides a fantastic analogy for understanding the difference between the development and build processes.
Read the sections from "How npm run build is different" to the end. It explains that while npm run dev serves files from memory for speed, npm run build is focused on optimization and creating physical files for deployment. The analogy of cooking versus packaging the final meal is particularly helpful.
Running the Command and Finding the Output
Now, let's connect this to the commands you see. When you type npm run build in your terminal, you are not running a built-in command of npm itself. You are running a script defined by the project's developers in the package.json file.
The scripts section of package.json is a set of shortcuts.
{
"name": "my-vibe-coded-app",
"version": "0.1.0",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "14.2.3",
"react": "18.3.1"
}
}
In this example, npm run build is simply an alias for the real command, next build. This makes it easy to remember and consistent across different projects.
When you run the command, you'll see a lot of text in your terminal as the build process does its work.

Once it's finished, you'll find a new folder in your project directory. This folder is usually named build or dist (for "distribution").
This short video demonstrates running the command and the creation of the build folder.
3 most popular npm commands, npm install, npm build and npm start in 2023
This video from Thank Code provides a straightforward demonstration of the npm build command.
Watch the segment from npm build. The presenter deletes the existing build folder, runs the command, and shows the new build folder being created with its optimized, static files inside.
This newly created folder contains the final, deployable version of your application. It’s a self-contained unit that a hosting service like Vercel can serve to the world.

This build/dist folder is the entire reason the build step exists. It's the tangible product of the process, ready for deployment. Everything Vercel needs to host your site is inside this single folder.
Conclusion
You now understand one of the most important, yet often confusing, steps in the journey from code to live app. The build command isn't just a bit of technical jargon; it's the bridge that transforms your developer-friendly project into a high-performance, user-ready website.
Key Takeaways:
- The Build Analogy: The build process is like slicing a 3D model. It converts your editable source code (
srcfolder) into an optimized, machine-ready format (buildordistfolder). - What
npm run buildDoes: It runs a script that transpiles, bundles, and minifies your code, making it compatible, small, and fast for browsers. - The Difference from
dev:npm run devis for fast, in-memory development, whilenpm run buildis for creating optimized files on disk for production. - The Output: The process creates a folder, typically named
buildordist, which contains all the static files (HTML, CSS, JS) needed to run your application. This is the folder that gets deployed.
In the last two lessons, we've covered the "why" of Vercel and the "what" of the build process. In our next lesson, we’ll put it all together. You'll connect a project from your GitHub account to Vercel and perform your first real deployment, seeing this entire workflow in action.