Nuxt 3 reached end of life on 31 July 2026
It no longer receives bug fixes or security patches. Upgrade to Nuxt 4 or get extended support from HeroDevs

nuxt dev

Source
dev 命令会在 http://localhost:3000 启动一个支持热模块替换的开发服务器
Terminal
npx nuxt dev [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--envName] [-e, --extends=<layer-name>] [--clear] [--no-f, --no-fork] [-p, --port] [-h, --host] [--clipboard] [-o, --open] [--https] [--publicURL] [--qr] [--public] [--tunnel] [--profile[=verbose]] [--sslCert] [--sslKey]

dev 命令会在 http://localhost:3000 启动一个支持热模块替换的开发服务器

参数

参数描述
ROOTDIR="."指定工作目录(默认值:.

选项

选项默认值描述
--cwd=<directory>指定工作目录,此选项优先于 ROOTDIR(默认值:.
--logLevel=<silent|info|verbose>指定构建时日志级别
--dotenv要加载的 .env 文件路径,相对于根目录
--envName解析配置覆盖时使用的环境(构建时默认为 production,运行开发服务器时默认为 development
-e, --extends=<layer-name>从 Nuxt layer 扩展
--clearfalse重启时清除控制台
--no-f, --no-fork禁用 fork 模式
-p, --port要监听的端口(默认值:NUXT_PORT || NITRO_PORT || PORT || nuxtOptions.devServer.port
-h, --host要监听的主机(默认值:NUXT_HOST || NITRO_HOST || HOST || nuxtOptions.devServer?.host
--clipboardfalse将 URL 复制到剪贴板
-o, --openfalse在浏览器中打开 URL
--https启用 HTTPS
--publicURL显示的公共 URL(用于二维码)
--qr可用时显示公共 URL 的二维码
--public监听所有网络接口
--tunnel使用 https://github.com/unjs/untun 打开隧道
--profile[=verbose]分析性能。使用 --profile 仅分析 CPU,使用 --profile=verbose 获取完整报告
--sslCert(已弃用)请改用 --https.cert
--sslKey(已弃用)请改用 --https.key

还可以通过 NUXT_PORT、PORT、NUXT_HOST 或 HOST 环境变量设置端口和主机。

除了上述选项之外,@nuxt/cli 还可以将选项传递给 listhen,例如使用 --no-qr 关闭开发服务器二维码。你可以在 unjs/listhen 文档中找到 listhen 选项列表。

此命令会将 process.env.NODE_ENV 设置为 development

如果你在开发环境中使用自签名证书,则需要在环境中设置 NODE_TLS_REJECT_UNAUTHORIZED=0