
- Next.js - Home
- Next.js - Overview
- Next.js - Project Setup
- Next.js - Folder Structure
- Next.js - App Router
- Next.js - Page Router
- Next.js Features
- Next.js - Pages
- Next.js - Data Fetching
- Next.js - ISR
- Next.js - Static File Serving
- Next.js - Pre-Rendering
- Next.js - Partial Pre Rendering
- Next.js - Server Side Rendering
- Next.js - Client Side Rendering
- Next.js Routing
- Next.js - Routing
- Next.js - Nested Routing
- Next.js - Dynamic Routing
- Next.js - Parallel Routing
- Next.js - Imperative Routing
- Next.js - Shallow Routing
- Next.js - Intercepting Routes
- Next.js - Redirecting Routes
- Next.js - Navigation and Linking
- Next.js Configuration
- Next.js - TypeScript
- Next.js - Environment Variables
- Next.js - File Conventions
- Next.js - ESLint
- Next.js API & Backend
- Next.js - API Routes
- Next.js - Dynamic API Routes
- Next.js - Route Handlers
- Next.js - API MiddleWares
- Next.js - Response Helpers
- Next.js API Reference
- Next.js - CLI Commands
- Next.js - Functions
- Next.js - Directives
- Next.js - Components
- Next.js - Image Component
- Next.js - Font Component
- Next.js - Head Component
- Next.js - Form Component
- Next.js - Link Component
- Next.js - Script Component
- Next.js Styling & SEO
- Next.js - CSS Support
- Next.js - Global CSS Support
- Next.js - Meta Data
- Next.js Advanced Topics
- Next.js - Error Handling
- Next.js - Server Actions
- Next.js - Fast Refresh
- Next.js - Internationalization
- Next.js - Authentication
- Next.js - Session Management
- Next.js - Authorization
- Next.js - Caching
- Next.js - Data Caching
- Next.js - Router Caching
- Next.js - Full Route Caching
- Next.js - Request Memoization
- Next.js Performance Optimization
- Next.js - Optimizations
- Next.js - Image Optimization
- Next.js - Lazy Loading
- Next.js - Font Optimization
- Next.js - Video Optimization
- Next.js - Script Optimization
- Next.js - Memory Optimization
- Next.js - Using OpenTelemetry
- Next.js - Package Bundling Optimization
- Next.js Testing
- Next.js - Testing
- Next.js - Testing with Jest
- Next.js - Testing with Cypress
- Next.js - Testing with Vitest
- Next.js - Testing with Playwright
- Next.js Debugging & Deployment
- Next.js - Debugging
- Next.js - Deployment
- Next.js Useful Resources
- Next.js - Interview Questions
- Next.js - Quick Guide
- Next.js - Useful Resources
- Next.js - Discussion
Next.js - CLI build Command
In Next.js CLI, the `build` command is used to create a production-ready build of a Next.js application. This command provides various options to customize the build process and environment. In this chapter, we will explain how to use the `build` command to create a customizable Next.js production build.
Next.js Build Command Syntax
Following is the syntax of the build command in Next.js CLI.
npx next build [options]
For example, npx next build --no-lint. Here, the production build will occur on current directory, with linting disabled.
Options of Build Command
Following is a list of options available for the `build` command.
Options | Explanation |
---|---|
-h, --help | Show all available options. |
[directory] | Specifies a directory to build the application. If not provided, the current directory is used. |
-d or --debug | Enables a more verbose build output. Includes additional build details like rewrites, redirects, and headers. |
--profile | Enables production profiling for React. |
--no-lint | Disables linting (error suggestion) during the build process. |
--no-mangling | Disables mangling, which might affect performance and is intended for debugging purposes. |
--experimental-app-only | Builds only App Router routes. |
--experimental-build-mode [mode] | Uses an experimental build mode. Choices include "compile", "generate", or the default "default". |
Specify Directory For Building App
If your current terminal directory does not contain Next.js project, then you can use `build` command with directory option to build app in a different directory. If you don't specify any directory, by default current directory is used for building app. Following is the syntax to specify the directory.
npx next build ./next-js-example
After running the above command in your terminal, the Next.js build process will create a production-ready version of the application located in the `./next-js-example` directory.
Output
In the output, app build occurs at specified directory.

Avoid linting on Building App
In Next.js build process, linting refers to the automatic checking of your code for potential issues, such as errors, style violations, or patterns that may lead to bugs. You can avoid linting using following command.
npx next build ./next-js-example --no-lint
Output
In the output, you can see the build process for the `./next-js-example` directory with linting disabled.
