Running Apps
You can run your Bit Apps using the bit run command, when an app is available and configured in your workspace.
Run an app using its app name (see the previous output example):
bit run hello-node-appCopied
Use --port to specify a specific port for your app to use. Ports forwarded using this flag would be available in your AppContext. If your app is not found, make sure it is configured on your workspace.
Listing apps
Run the following to list all available apps in your workspace:
bit app listCopied
The output should include the apps' name and component id:
┌───────────────────────────────────┬────────────────┐ │ id │ name │ ├───────────────────────────────────┼────────────────┤ │ learnbit.apps/node-app │ hello-node-app │ └───────────────────────────────────┴────────────────┘Copied
Compile upon changes
You can use --watch flag to watch for component changes and compile while running your apps, by running the following command:
bit run hello-node-app --watchCopied
Setting apps
Apps needs to be configured to run on your workspace. Use the following command to configure an app on your workspace:
bit use my-appCopied
Running this command will add the required configuration to your workspace.jsonc file:
{ "learnbit.apps/node-app": {} }Copied
Build an app runner
You can create an app runner by implementing a run function for your Bit app:
import type { AppContext } from '@teambit/application'; export function run(context: AppContext) { const rootPath = context.hostRootDir; const child = execFile(rootDir, [mainFile], { cwd: rootPath, }, (error) => { if (error) throw error; }); }Copied
The example above runs a NodeJS module in a new NodeJS process. Use this function from your *.bit-app.ts file.