Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Nuxt 3.x reference covering SSR, file-based routing, auto-imports, server routes, and Nitro deployment.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/core-cli.md
1---2name: cli-commands3description: Nuxt CLI commands for development, building, and project management4---56# CLI Commands78Nuxt provides CLI commands via `nuxi` (or `npx nuxt`) for development, building, and project management.910## Project Initialization1112### Create New Project1314```bash15# Interactive project creation16npx nuxi@latest init my-app1718# With specific package manager19npx nuxi@latest init my-app --packageManager pnpm2021# With modules22npx nuxi@latest init my-app --modules "@nuxt/ui,@nuxt/image"2324# From template25npx nuxi@latest init my-app --template v32627# Skip module selection prompt28npx nuxi@latest init my-app --no-modules29```3031**Options:**32| Option | Description |33|--------|-------------|34| `-t, --template` | Template name |35| `--packageManager` | npm, pnpm, yarn, or bun |36| `-M, --modules` | Modules to install (comma-separated) |37| `--gitInit` | Initialize git repository |38| `--no-install` | Skip installing dependencies |3940## Development4142### Start Dev Server4344```bash45# Start development server (default: http://localhost:3000)46npx nuxt dev4748# Custom port49npx nuxt dev --port 40005051# Open in browser52npx nuxt dev --open5354# Listen on all interfaces (for mobile testing)55npx nuxt dev --host 0.0.0.05657# With HTTPS58npx nuxt dev --https5960# Clear console on restart61npx nuxt dev --clear6263# Create public tunnel64npx nuxt dev --tunnel65```6667**Options:**68| Option | Description |69|--------|-------------|70| `-p, --port` | Port to listen on |71| `-h, --host` | Host to listen on |72| `-o, --open` | Open in browser |73| `--https` | Enable HTTPS |74| `--tunnel` | Create public tunnel (via untun) |75| `--qr` | Show QR code for mobile |76| `--clear` | Clear console on restart |7778**Environment Variables:**79- `NUXT_PORT` or `PORT` - Default port80- `NUXT_HOST` or `HOST` - Default host8182## Building8384### Production Build8586```bash87# Build for production88npx nuxt build8990# Build with prerendering91npx nuxt build --prerender9293# Build with specific preset94npx nuxt build --preset node-server95npx nuxt build --preset cloudflare-pages96npx nuxt build --preset vercel9798# Build with environment99npx nuxt build --envName staging100```101102Output is created in `.output/` directory.103104### Static Generation105106```bash107# Generate static site (prerenders all routes)108npx nuxt generate109```110111Equivalent to `nuxt build --prerender`. Creates static HTML files for deployment to static hosting.112113### Preview Production Build114115```bash116# Preview after build117npx nuxt preview118119# Custom port120npx nuxt preview --port 4000121```122123## Utilities124125### Prepare (Type Generation)126127```bash128# Generate TypeScript types and .nuxt directory129npx nuxt prepare130```131132Run after cloning or when types are missing.133134### Type Check135136```bash137# Run TypeScript type checking138npx nuxt typecheck139```140141### Analyze Bundle142143```bash144# Analyze production bundle145npx nuxt analyze146```147148Opens visual bundle analyzer.149150### Cleanup151152```bash153# Remove generated files (.nuxt, .output, node_modules/.cache)154npx nuxt cleanup155```156157### Info158159```bash160# Show environment info (useful for bug reports)161npx nuxt info162```163164### Upgrade165166```bash167# Upgrade Nuxt to latest version168npx nuxt upgrade169170# Upgrade to nightly release171npx nuxt upgrade --nightly172```173174## Module Commands175176### Add Module177178```bash179# Add a Nuxt module180npx nuxt module add @nuxt/ui181npx nuxt module add @nuxt/image182```183184Installs and adds to `nuxt.config.ts`.185186### Build Module (for module authors)187188```bash189# Build a Nuxt module190npx nuxt build-module191```192193## DevTools194195```bash196# Enable DevTools globally197npx nuxt devtools enable198199# Disable DevTools200npx nuxt devtools disable201```202203## Common Workflows204205### Development206207```bash208# Install dependencies and start dev209pnpm install210pnpm dev # or npx nuxt dev211```212213### Production Deployment214215```bash216# Build and preview locally217pnpm build218pnpm preview219220# Or for static hosting221pnpm generate222```223224### After Cloning225226```bash227# Install deps and prepare types228pnpm install229npx nuxt prepare230```231232## Environment-specific Builds233234```bash235# Development build236npx nuxt build --envName development237238# Staging build239npx nuxt build --envName staging240241# Production build (default)242npx nuxt build --envName production243```244245Corresponds to `$development`, `$env.staging`, `$production` in `nuxt.config.ts`.246247## Layer Extension248249```bash250# Dev with additional layer251npx nuxt dev --extends ./base-layer252253# Build with layer254npx nuxt build --extends ./base-layer255```256257<!--258Source references:259- https://nuxt.com/docs/api/commands/dev260- https://nuxt.com/docs/api/commands/build261- https://nuxt.com/docs/api/commands/generate262- https://nuxt.com/docs/api/commands/init263-->264