1. Install the SWA CLI
You can install the Static Web Apps CLI using either npm
or yarn
.
Install with npm
See: @azure/static-web-apps-cli .
- To install this globally, use:
npm install -g @azure/static-web-apps-cli
- The recommended approach is to install this locally, as a devDependency using:
npm install -D @azure/static-web-apps-cli
Install with yarn
See: @azure/static-web-apps-cli.
- To install this globally, use:
yarn add global @azure/static-web-apps-cli
- The recommended approach is to install this locally, as a devDependency, using:
yarn add -D @azure/static-web-apps-cli
Validate the install
Installing the package should make the swa command available on your development machine. To validate, try using the command with an appropriate option.
For instance, check the installed version.
$ swa --version
0.8.3
Run using npx
The npx command (aka "npm exec") lets you run an arbitrary command from a local or remote npm package. If the command was not installed globally on the device, this installs it for you in a central cache - making it a useful option if you want to use different versions of the same command on the local device.
We can now run any Static Web Apps CLI commands directly using npx - for example: check the version as follows:
$ npx @azure/static-web-apps-cli --version
Or use this command to start the emulator on your local device:
$ npx @azure/static-web-apps-cli start