nuxi dev
dev 命令会在 [http://localhost:3000](http://localhost:3000) 处启动一个带有热模块替换功能的开发服务器。
Terminal
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
命令会在 [http://localhost:3000](https://localhost:3000) 启动一个带有热模块替换功能的开发服务器。
¥The dev
command starts a development server with hot module replacement at http://localhost:3000
参数
¥Arguments
参数 | 描述 |
---|---|
ROOTDIR="." | 指定工作目录(默认值:. ) |
选项
¥Options
选项 | 默认 | 描述 |
---|---|---|
--cwd=<directory> | 指定工作目录,该目录优先于 ROOTDIR(默认值:. ) | |
--logLevel=<silent|info|verbose> | 指定构建时日志级别 | |
--dotenv | 要加载的 .env 文件的路径,相对于根目录 | |
--envName | 解析配置覆盖时使用的环境(构建时默认为 production ,运行开发服务器时默认为 development ) | |
--no-clear | 禁用重启时清除控制台的功能 | |
--no-fork | 禁用分叉模式 | |
-p, --port | 监听端口(默认值:NUXT_PORT || NITRO_PORT || PORT || nuxtOptions.devServer.port ) | |
-h, --host | 监听的主机(默认值:NUXT_HOST || NITRO_HOST || HOST || nuxtOptions._layers?.[0]?.devServer?.host ) | |
--clipboard | false | 将 URL 复制到剪贴板 |
-o, --open | false | 在浏览器中打开 URL |
--https | 启用 HTTPS | |
--publicURL | 显示的公共 URL(用于二维码) | |
--qr | 显示公共 URL 的二维码(可用时) | |
--public | 监听所有网络接口 | |
--tunnel | 使用 https://github.com/unjs/untun 打开隧道 | |
--sslCert | (DEPRECATED)改用 --https.cert 。 | |
--sslKey | (DEPRECATED)改用 --https.key 。 |
端口和主机也可以通过 NUXT_PORT、PORT、NUXT_HOST 或 HOST 环境变量设置。
¥The port and host can also be set via NUXT_PORT, PORT, NUXT_HOST or HOST environment variables.
除了上述选项外,nuxi
还可以将选项传递给 listhen
,例如 --no-qr
可以关闭开发服务器二维码。你可以在 unjs/listhen 文档中找到 listhen
选项列表。
¥Additionally to the above options, nuxi
can pass options through to listhen
, e.g. --no-qr
to turn off the dev server QR code. You can find the list of listhen
options in the unjs/listhen docs.
此命令将 process.env.NODE_ENV
设置为 development
。
¥This command sets process.env.NODE_ENV
to development
.
如果你在开发中使用自签名证书,则需要在环境中设置
NODE_TLS_REJECT_UNAUTHORIZED=0
。