docs: update nuxi command pages (#30199)

This commit is contained in:
Bobbie Goede 2024-12-18 11:29:56 +01:00 committed by GitHub
parent 8de9c5be50
commit c83507e315
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 349 additions and 99 deletions

View File

@ -8,16 +8,30 @@ links:
size: xs
---
<!--add-cmd-->
```bash [Terminal]
npx nuxi add [--cwd] [--force] <TEMPLATE> <NAME>
npx nuxi add <TEMPLATE> <NAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--force]
```
<!--/add-cmd-->
Option | Default | Description
-------------------------|-----------------|------------------
`TEMPLATE` | - | Specify a template of the file to be generated.
`NAME` | - | Specify a name of the file that will be created.
`--cwd` | `.` | The directory of the target application.
`--force` | `false` | Force override file if it already exists.
### Arguments
<!--add-args-->
Argument | Description
--- | ---
`TEMPLATE` | Specify which template to generate (options: <api\|plugin\|component\|composable\|middleware\|layout\|page>)
`NAME` | Specify name of the generated file
<!--/add-args-->
### Options
<!--add-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | `.` | Specify the working directory
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--force` | `false` | Force override file if it already exists
<!--/add-opts-->
**Modifiers:**

View File

@ -8,15 +8,33 @@ links:
size: xs
---
<!--analyze-cmd-->
```bash [Terminal]
npx nuxi analyze [--log-level] [rootDir]
npx nuxi analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--name=<name>] [--no-serve]
```
<!--/analyze-cmd-->
The `analyze` command builds Nuxt and analyzes the production bundle (experimental).
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The directory of the target application.
## Arguments
<!--analyze-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/analyze-args-->
## Options
<!--analyze-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--dotenv` | | Path to `.env` file to load, relative to the root directory
`--name=<name>` | `default` | Name of the analysis
`--no-serve` | | Skip serving the analysis results
<!--/analyze-opts-->
::note
This command sets `process.env.NODE_ENV` to `production`.

View File

@ -8,17 +8,35 @@ links:
size: xs
---
<!--build-module-cmd-->
```bash [Terminal]
npx nuxi build-module [--stub] [rootDir]
npx nuxi build-module [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--build] [--stub] [--sourcemap] [--prepare]
```
<!--/build-module-cmd-->
The `build-module` command runs `@nuxt/module-builder` to generate `dist` directory within your `rootDir` that contains the full build for your **nuxt-module**.
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The root directory of the module to bundle.
`--stub` | `false` | Stub out your module for development using [jiti](https://github.com/unjs/jiti#jiti). (**note:** This is mainly for development purposes.)
## Arguments
::read-more{to="https://github.com/nuxt/module-builder" icon="i-simple-icons-github" color="gray" target="_blank"}
<!--build-module-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/build-module-args-->
## Options
<!--build-module-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--build` | `false` | Build module for distribution
`--stub` | `false` | Stub dist instead of actually building it for development
`--sourcemap` | `false` | Generate sourcemaps
`--prepare` | `false` | Prepare module for local development
<!--/build-module-opts-->
::read-more{to="https://github.com/nuxt/module-builder" icon="i-simple-icons-github" color="gray" target="\_blank"}
Read more about `@nuxt/module-builder`.
::

View File

@ -8,19 +8,34 @@ links:
size: xs
---
<!--build-cmd-->
```bash [Terminal]
npx nuxi build [--prerender] [--preset] [--dotenv] [--log-level] [rootDir]
npx nuxi build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName]
```
<!--/build-cmd-->
The `build` command creates a `.output` directory with all your application, server and dependencies ready for production.
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The root directory of the application to bundle.
`--prerender` | `false` | Pre-render every route of your application. (**note:** This is an experimental flag. The behavior might be changed.)
`--preset` | - | Set a [Nitro preset](https://nitro.unjs.io/deploy#changing-the-deployment-preset)
`--dotenv` | `.` | Point to another `.env` file to load, **relative** to the root directory.
`--log-level` | `info` | Specify build-time logging level, allowing `silent` \| `info` \| `verbose`.
## Arguments
<!--build-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/build-args-->
## Options
<!--build-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--prerender` | | Build Nuxt and prerender static routes
`--preset` | | Nitro server preset
`--dotenv` | | Path to `.env` file to load, relative to the root directory
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
<!--/build-opts-->
::note
This command sets `process.env.NODE_ENV` to `production`.

View File

@ -1,6 +1,6 @@
---
title: 'nuxi cleanup'
description: "Remove common generated Nuxt files and caches."
description: 'Remove common generated Nuxt files and caches.'
links:
- label: Source
icon: i-simple-icons-github
@ -8,16 +8,31 @@ links:
size: xs
---
<!--cleanup-cmd-->
```bash [Terminal]
npx nuxi cleanup [rootDir]
npx nuxi cleanup [ROOTDIR] [--cwd=<directory>]
```
<!--/cleanup-cmd-->
The `cleanup` command removes common generated Nuxt files and caches, including:
- `.nuxt`
- `.output`
- `node_modules/.vite`
- `node_modules/.cache`
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The root directory of the project.
## Arguments
<!--cleanup-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/cleanup-args-->
## Options
<!--cleanup-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
<!--/cleanup-opts-->

View File

@ -8,25 +8,45 @@ links:
size: xs
---
<!--dev-cmd-->
```bash [Terminal]
npx nuxi dev [rootDir] [--dotenv] [--log-level] [--clipboard] [--open, -o] [--no-clear] [--port, -p] [--host, -h] [--https] [--ssl-cert] [--ssl-key] [--tunnel]
npx nuxi dev [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--envName] [--no-clear] [--no-fork] [-p, --port] [-h, --host] [--clipboard] [-o, --open] [--https] [--publicURL] [--qr] [--public] [--tunnel] [--sslCert] [--sslKey]
```
<!--/dev-cmd-->
The `dev` command starts a development server with hot module replacement at [http://localhost:3000](https://localhost:3000)
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The root directory of the application to serve.
`--dotenv` | `.` | Point to another `.env` file to load, **relative** to the root directory.
`--open, -o` | `false` | Open URL in browser.
`--clipboard` | `false` | Copy URL to clipboard.
`--no-clear` | `false` | Does not clear the console after startup.
`--port, -p` | `3000` | Port to listen.
`--host, -h` | `localhost` | Hostname of the server.
`--https` | `false` | Listen with `https` protocol with a self-signed certificate by default.
`--ssl-cert` |`null` | Specify a certificate for https.
`--ssl-key` |`null` | Specify the key for the https certificate.
`--tunnel` | `false` | Tunnel your local server to the internet with [unjs/untun](https://github.com/unjs/untun)
## Arguments
<!--dev-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/dev-args-->
## Options
<!--dev-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--dotenv` | | Path to `.env` file to load, relative to the root directory
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
`--no-clear` | | Disable clear console on restart
`--no-fork` | | Disable forked mode
`-p, --port` | | Port to listen on (default: `NUXT_PORT \|\| NITRO_PORT \|\| PORT \|\| nuxtOptions.devServer.port`)
`-h, --host` | | Host to listen on (default: `NUXT_HOST \|\| NITRO_HOST \|\| HOST \|\| nuxtOptions._layers?.[0]?.devServer?.host`)
`--clipboard` | `false` | Copy the URL to the clipboard
`-o, --open` | `false` | Open the URL in the browser
`--https` | | Enable HTTPS
`--publicURL` | | Displayed public URL (used for QR code)
`--qr` | | Display The QR code of public URL when available
`--public` | | Listen to all network interfaces
`--tunnel` | | Open a tunnel using https://github.com/unjs/untun
`--sslCert` | | (DEPRECATED) Use `--https.cert` instead.
`--sslKey` | | (DEPRECATED) Use `--https.key` instead.
<!--/dev-opts-->
The port and host can also be set via NUXT_PORT, PORT, NUXT_HOST or HOST environment variables.

View File

@ -8,16 +8,31 @@ links:
size: xs
---
<!--devtools-cmd-->
```bash [Terminal]
npx nuxi devtools enable|disable [rootDir]
npx nuxi devtools <COMMAND> [ROOTDIR] [--cwd=<directory>]
```
<!--/devtools-cmd-->
Running `nuxi devtools enable` will install the Nuxt DevTools globally, and also enable it within the particular project you are using. It is saved as a preference in your user-level `.nuxtrc`. If you want to remove devtools support for a particular project, you can run `nuxi devtools disable`.
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The root directory of the app you want to enable devtools for.
## Arguments
::read-more{icon="i-simple-icons-nuxtdotjs" to="https://devtools.nuxt.com" target="_blank"}
<!--devtools-args-->
Argument | Description
--- | ---
`COMMAND` | Command to run (options: <enable\|disable>)
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/devtools-args-->
## Options
<!--devtools-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
<!--/devtools-opts-->
::read-more{icon="i-simple-icons-nuxtdotjs" to="https://devtools.nuxt.com" target="\_blank"}
Read more about the **Nuxt DevTools**.
::

View File

@ -8,16 +8,33 @@ links:
size: xs
---
<!--generate-cmd-->
```bash [Terminal]
npx nuxi generate [rootDir] [--dotenv]
npx nuxi generate [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--preset] [--dotenv] [--envName]
```
<!--/generate-cmd-->
The `generate` command pre-renders every route of your application and stores the result in plain HTML files that you can deploy on any static hosting services. The command triggers the `nuxi build` command with the `prerender` argument set to `true`
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The root directory of the application to generate
`--dotenv` | `.` | Point to another `.env` file to load, **relative** to the root directory.
## Arguments
<!--generate-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/generate-args-->
## Options
<!--generate-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--preset` | | Nitro server preset
`--dotenv` | | Path to `.env` file to load, relative to the root directory
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
<!--/generate-opts-->
::read-more{to="/docs/getting-started/deployment#static-hosting"}
Read more about pre-rendering and static hosting.

View File

@ -8,12 +8,26 @@ links:
size: xs
---
<!--info-cmd-->
```bash [Terminal]
npx nuxi info [rootDir]
npx nuxi info [ROOTDIR] [--cwd=<directory>]
```
<!--/info-cmd-->
The `info` command logs information about the current or specified Nuxt project.
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The directory of the target application.
## Arguments
<!--info-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/info-args-->
## Options
<!--info-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
<!--/info-opts-->

View File

@ -8,27 +8,37 @@ links:
size: xs
---
<!--init-cmd-->
```bash [Terminal]
npx nuxi init [--verbose|-v] [--template,-t] [dir]
npx nuxi init [DIR] [--cwd=<directory>] [-t, --template] [-f, --force] [--offline] [--preferOffline] [--no-install] [--gitInit] [--shell] [--packageManager]
```
<!--/init-cmd-->
The `init` command initializes a fresh Nuxt project using [unjs/giget](https://github.com/unjs/giget).
## Arguments
<!--init-args-->
Argument | Description
--- | ---
`DIR=""` | Project directory
<!--/init-args-->
## Options
Option | Default | Description
-------------------------|-----------------|------------------
`--cwd` | | Current working directory
`--log-level` | | Log level
`--template, -t` | `v3` | Specify template name or git repository to use as a template. Format is `gh:org/name` to use a custom github template.
`--force, -f` | `false` | Force clone to any existing directory.
`--offline` | `false` | Force offline mode (do not attempt to download template from GitHub and only use local cache).
`--prefer-offline` | `false` | Prefer offline mode (try local cache first to download templates).
`--no-install` | `false` | Skip installing dependencies.
`--git-init` | `false` | Initialize git repository.
`--shell` | `false` | Start shell after installation in project directory (experimental).
`--package-manager` | `npm` | Package manager choice (npm, pnpm, yarn, bun).
`--dir` | | Project directory.
<!--init-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | `.` | Specify the working directory
`-t, --template` | | Template name
`-f, --force` | | Override existing directory
`--offline` | | Force offline mode
`--preferOffline` | | Prefer offline mode
`--no-install` | | Skip installing dependencies
`--gitInit` | | Initialize git repository
`--shell` | | Start shell after installation in project directory
`--packageManager` | | Package manager choice (npm, pnpm, yarn, bun)
<!--/init-opts-->
## Environment variables

View File

@ -12,17 +12,31 @@ Nuxi provides a few utilities to work with [Nuxt modules](/modules) seamlessly.
## nuxi module add
<!--module-add-cmd-->
```bash [Terminal]
npx nuxi module add <NAME>
npx nuxi module add <MODULENAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--skipInstall] [--skipConfig]
```
<!--/module-add-cmd-->
Option | Default | Description
-------------------------|-----------------|------------------
`NAME` | - | The name of the module to install.
<!--module-add-args-->
Argument | Description
--- | ---
`MODULENAME` | Module name
<!--/module-add-args-->
<!--module-add-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | `.` | Specify the working directory
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--skipInstall` | | Skip npm install
`--skipConfig` | | Skip nuxt.config.ts update
<!--/module-add-opts-->
The command lets you install [Nuxt modules](/modules) in your application with no manual work.
When running the command, it will:
- install the module as a dependency using your package manager
- add it to your [package.json](/docs/guide/directory-structure/package) file
- update your [`nuxt.config`](/docs/guide/directory-structure/nuxt-config) file
@ -30,19 +44,35 @@ When running the command, it will:
**Example:**
Installing the [`Pinia`](/modules/pinia) module
```bash [Terminal]
npx nuxi module add pinia
```
## nuxi module search
<!--module-search-cmd-->
```bash [Terminal]
npx nuxi module search <QUERY>
npx nuxi module search <QUERY> [--cwd=<directory>] [--nuxtVersion=<2|3>]
```
<!--/module-search-cmd-->
Option | Default | Description
-------------------------|-----------------|------------------
`QUERY` | - | The name of the module to search for.
### Arguments
<!--module-search-args-->
Argument | Description
--- | ---
`QUERY` | keywords to search for
<!--/module-search-args-->
### Options
<!--module-search-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | `.` | Specify the working directory
`--nuxtVersion=<2\|3>` | | Filter by Nuxt version and list compatible modules only (auto detected by default)
<!--/module-search-opts-->
The command searches for Nuxt modules matching your query that are compatible with your Nuxt version.

View File

@ -8,12 +8,29 @@ links:
size: xs
---
<!--prepare-cmd-->
```bash [Terminal]
npx nuxi prepare [--log-level] [rootDir]
npx nuxi prepare [ROOTDIR] [--dotenv] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName]
```
<!--/prepare-cmd-->
The `prepare` command creates a [`.nuxt`](/docs/guide/directory-structure/nuxt) directory in your application and generates types. This can be useful in a CI environment or as a `postinstall` command in your [`package.json`](/docs/guide/directory-structure/package).
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The root directory of the application to prepare.
## Arguments
<!--prepare-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/prepare-args-->
## Options
<!--prepare-opts-->
Option | Default | Description
--- | --- | ---
`--dotenv` | | Path to `.env` file to load, relative to the root directory
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
<!--/prepare-opts-->

View File

@ -8,16 +8,32 @@ links:
size: xs
---
<!--preview-cmd-->
```bash [Terminal]
npx nuxi preview|start [rootDir] [--dotenv]
npx nuxi preview [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName] [--dotenv]
```
<!--/preview-cmd-->
The `preview` command starts a server to preview your Nuxt application after running the `build` command. The `start` command is an alias for `preview`. When running your application in production refer to the [Deployment section](/docs/getting-started/deployment).
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The root directory of the application to preview.
`--dotenv` | `.` | Point to another `.env` file to load, **relative** to the root directory.
## Arguments
<!--preview-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/preview-args-->
## Options
<!--preview-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
`--dotenv` | | Path to `.env` file to load, relative to the root directory
<!--/preview-opts-->
This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a `.env` file or as command-line argument.

View File

@ -8,15 +8,30 @@ links:
size: xs
---
<!--typecheck-cmd-->
```bash [Terminal]
npx nuxi typecheck [--log-level] [rootDir]
npx nuxi typecheck [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>]
```
<!--/typecheck-cmd-->
The `typecheck` command runs [`vue-tsc`](https://github.com/vuejs/language-tools/tree/master/packages/tsc) to check types throughout your app.
Option | Default | Description
-------------------------|-----------------|------------------
`rootDir` | `.` | The directory of the target application.
## Arguments
<!--typecheck-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/typecheck-args-->
## Options
<!--typecheck-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
<!--/typecheck-opts-->
::note
This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a [`.env`](/docs/guide/directory-structure/env) file or as a command-line argument.

View File

@ -8,13 +8,29 @@ links:
size: xs
---
<!--upgrade-cmd-->
```bash [Terminal]
npx nuxi upgrade [--force|-f]
npx nuxi upgrade [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [-f, --force] [-ch, --channel=<stable|nightly>]
```
<!--/upgrade-cmd-->
The `upgrade` command upgrades Nuxt to the latest version.
Option | Default | Description
-------------------------|-----------------|------------------
`--force, -f` | `false` | Removes `node_modules` and lock files before upgrade.
`--channel, -ch` | `"stable"` | Specify a channel to install from ("nightly" or "stable")
## Arguments
<!--upgrade-args-->
Argument | Description
--- | ---
`ROOTDIR="."` | Specifies the working directory (default: `.`)
<!--/upgrade-args-->
## Options
<!--upgrade-opts-->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`-f, --force` | | Force upgrade to recreate lockfile and node_modules
`-ch, --channel=<stable\|nightly>` | `stable` | Specify a channel to install from (default: stable)
<!--/upgrade-opts-->