Run Locally
Knapsack CLI
- Knapsack uses a tool called the Knapsack CLI (Command Line Interface). It gets installed from the
@knapsack/apppackage and should be located in the./node_modules/.bin/knapsackfolder. - You’ll run Knapsack commands via NPM Scripts (from your package.json file).
Available Commands
Here’s a list of the most important Knapsack commands you’ll use. They all start with knapsack (e.g., knapsack start):
Example: Package.json with Knapsack Commands
Here’s an example of how your package.json might look after adding Knapsack commands. These commands make it easy to run Knapsack from your terminal:
You can run these commands like this:
Enabling HTTPS Mode for Local Development
You can enable HTTPS (secure connection) when running Knapsack locally, which is useful when developing with services that require HTTPS.
Knapsack lets you use either automatic SSL certificates (recommended) or your own custom SSL certificate.
Option 1: Using Automatic SSL Certificate (Recommended)
To enable HTTPS automatically, add this to your knapsack.config.js file:
Option 2: Using a Custom SSL Certificate
If you have your own SSL certificate, you can configure Knapsack to use it. Add this to your knapsack.config.js file:
Note: When you run the start command for the first time after setting up HTTPS, you might be asked for your password. This allows mkcert to create and register your SSL certificate securely.