@azure/static-web-apps-cli

中文文档
2.1.0发布于 2026/10/20MITES Module近 30 天下载 63万

Azure Static Web Apps CLI

原始使用文档
文档目录8 节
  1. Azure Static Web Apps CLI
  2. Important Notes
  3. Quickstart
  4. Installing the CLI with npm , yarn or pnpm :
  5. Basic usage
  6. Extended usage
  7. Using npx :
  8. Want to help?

Azure Static Web Apps CLI

NPM version Node version CI status Contributions welcome

logo

The Static Web Apps CLI, also known as SWA CLI, serves as a local development tool for Azure Static Web Apps. It can:

  • Serve static app assets, or proxy to your app dev server
  • Serve API requests, or proxy to APIs running in Azure Functions Core Tools
  • Emulate authentication and authorization
  • Emulate Static Web Apps configuration, including routing and ACL roles
  • Deploy your app to Azure Static Web Apps

Important Notes

If you have suggestions or you encounter issues, please report them or help us fix them. Your contributions are very much appreciated. 🙏

The CLI emulates commonly used capabilities of the Azure Static Web Apps cloud service. Some differences are expected. Always deploy and test your apps in Azure to confirm behavior.

Quickstart

Installing the CLI with npm, yarn or pnpm:

  • To install the CLI in your project, use:

    npm install -D @azure/static-web-apps-cli
    

    You can also install the SWA CLI globally using npm install -g @azure/static-web-apps-cli.

Basic usage

  • Open a SWA app folder at the root (outside any /api or /app folders):

    cd my-awesome-swa-app
    
  • The best way to get started is to run the swa command alone and follow the interactive prompts:

    swa
    

It will generate a configuration for you, then build your project and ask if you want to deploy it to Azure.

See swa for more details.

Extended usage

Here are the currently supported swa commands. Use swa <command> --help to learn about options and usage for that particular command.

  • login: login into Azure
  • init: initialize a new static web app project
  • start: start the emulator from a directory or bind to a dev server
  • deploy: deploy the current project to Azure Static Web Apps
  • build: build your project

Using npx:

  • Open a SWA app folder at the root (outside any /api or /app folders):
cd my-awesome-swa-app
  • Create a configuration for your project:
npx @azure/static-web-apps-cli init
  • Start the emulator:
npx @azure/static-web-apps-cli start
  • Access your SWA app from http://localhost:4280

See all available commands and options.

Want to help?

Want to file a bug, contribute some code, or improve the documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the list: community-help.

版本与发布记录

@azure/static-web-apps-cli 共发布 45 个版本,首次发布于 2021/02/17;过去 12 个月发布了 4 个版本。

版本发布日期距今
2.1.0latest2026/10/2018 天前
2.0.102026/07/203 个月前
2.0.92026/04/216 个月前
2.0.82026/02/039 个月前
2.0.72025/09/181.1 年前
2.0.62025/04/291.5 年前

关于 @azure/static-web-apps-cli 的常见问题

@azure/static-web-apps-cli 是什么?

Azure Static Web Apps CLI

如何安装 @azure/static-web-apps-cli?

在项目目录运行 npm install @azure/static-web-apps-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 swa,可以用 npx swa 直接运行。

@azure/static-web-apps-cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/azure__static-web-apps-cli 是否存在。

@azure/static-web-apps-cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@azure/static-web-apps-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@azure/static-web-apps-cli 可以商用吗?

@azure/static-web-apps-cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@azure/static-web-apps-cli 的下载量有多少?

根据 npm 官方下载统计,@azure/static-web-apps-cli 在 2026/10/08 – 2026/11/06 这 30 天内被下载 629,696 次,日均约 20,990 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@azure/static-web-apps-cli 还在维护吗?

最新版本 2.1.0 发布于 2026/10/20(18 天前);至今共发布 45 个版本,其中过去 12 个月发布了 4 个;首次发布于 2021/02/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。