ng Verified current stable Not installed? Build Tools

Ng / Build Angular Output Path

Build Angular Output Path

Build Angular application with output directed to a specific path.

$
Terminal
ng b --output-path <path/to/directory>

When To Use

During deployment to specify the correct directory structure for hosting.

Pro Tip

If the specified path does not exist, the CLI will create it; ensure proper permissions are set on your filesystem.

Anatomy of Output

Understanding the result

Building: my-app | Output Path: dist/my-app Build Operation Details

Highlights the project being built and the target directory.

Build Size: 42MB Output Size

Indicates the size of files being generated.

Status: build completed successfully Build Completion Status

Confirms completion of the build process.

Power User Variants

Optimized versions

ng build --output-path=dist/my-new-app

Alternative command syntax to specify output path.

ng build --output-path ./dist/my-app

Using relative paths for output.

Troubleshooting

Common pitfalls

Error: Output path 'path/to/directory' is not writable.

Solution: Check directory permissions for the specified output path.

Error: Build failed due to configuration error.

Solution: Inspect configuration files for correctness.

Error: Project not found in the workspace.

Solution: Ensure the project name is correct and initialized.

Command Breakdown

What each part is doing

ng
Base Command
The executable that performs this operation. Here it runs Ng before the shell applies any redirect operators.
b
b|build
The value supplied for b|build.
<path/to/directory>
path to directory
The directory path supplied to this command.
--output-path
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative build tools tools for the same job.