- Next.js 教程
- Next.js - 首頁
- Next.js - 概述
- Next.js - 環境設定
- Next.js 功能
- Next.js - 頁面
- Next.js - 靜態檔案服務
- Next.js - 元資料
- Next.js - CSS 支援
- Next.js - 全域性 CSS 支援
- Next.js - 預渲染
- Next.js 路由
- Next.js - 路由
- Next.js - 動態 API 路由
- Next.js - 命令式路由
- Next.js - 淺路由
- Next.js API 路由
- Next.js - API 路由
- Next.js - API 中介軟體
- Next.js - 響應助手
- Next.js 其他
- Next.js - Typescript
- Next.js - 環境變數
- Next.js - 部署
- Next.js - CLI
- Next.js 有用資源
- Next.js - 快速指南
- Next.js - 有用資源
- Next.js - 討論
Next.js - CLI
NEXT.JS 提供了一個 CLI 來啟動、構建和匯出應用程式。它可以使用 npx(從 npm 5.2 開始)進行呼叫。
CLI 幫助
要獲取 CLI 命令及其幫助的列表,請鍵入以下命令。
npx next -h
Usage
$ next <command>
Available commands
build, start, export, dev, telemetry
Options
--version, -v Version number
--help, -h Displays this message
For more information run a command with the --help flag
$ next build --help
構建生產就緒構建
鍵入以下命令。
npx next build
info - Loaded env from D:\Node\nextjs\.env.local
Creating an optimized production build
Compiled successfully.
Automatically optimizing pages
Page Size First Load JS
+ ? / 2.25 kB 60.3 kB
+ /_app 288 B 58.1 kB
+ /404 3.25 kB 61.3 kB
+ ? /api/user
+ ? /posts/[id] 312 B 61.6 kB
+ + /posts/one
+ + /posts/two
+ ? /posts/env 2.71 kB 60.8 kB
+ ? /posts/first 374 B 61.7 kB
+ First Load JS shared by all 58.1 kB
+ static/pages/_app.js 288 B
+ chunks/ab55cb957ceed242a750c37a082143fb9d2f0cdf.a1a019.js 10.5 kB
+ chunks/framework.c6faae.js 40 kB
+ runtime/main.60464f.js 6.54 kB
+ runtime/webpack.c21266.js 746 B
+ css/9706b5b8ed8e82c0fba0.css 175 B
? (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
(Static) automatically rendered as static HTML (uses no initial props)
? (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
構建並啟動開發伺服器
鍵入以下命令。
npx next dev ready - started server on https://:3000 info - Loaded env from D:\Node\nextjs\.env.local event - compiled successfully
啟動生產伺服器
鍵入以下命令。
npx next start info - Loaded env from \Node\nextjs\.env.local ready - started server on https://:3000
廣告