Running & Debugging
This section covers how to run and debug scripts that you create using the framework.
Running the application
As you will have seen in the Quickstart section, we have defined a few scripts in the package.json
file, these are:
json
"scripts": {
"dev": "SODACORE_ENV=dev bun run ./src/main.ts",
"start": "SODACORE_ENV=prod bun run ./dist/main.js",
"build": "rm -rf ./dist && bun tsc --project ./tsconfig.json"
}
- The
dev
script will run the application in development mode. - The
start
script will run the application in production mode, this assumes you have built the application first using thebuild
script. - The
build
script will compile the TypeScript code into JavaScript, and place it in
Debugging
You can append the --inspect
flag to the bun run
command to enable debugging, for example:
json
"scripts": {
"dev": "SODACORE_ENV=dev bun run --inspect ./src/main.ts",
"start": "SODACORE_ENV=prod bun run ./dist/main.js",
"build": "rm -rf ./dist && bun tsc --project ./tsconfig.json"
}
Like Node.js, this will start a debugging server that you can connect to using a debugger client, such as the Chrome DevTools or VSCode.
Auto-restart
When running in development mode, you may want to have the application automatically restart when you make changes to the code. You can achieve this using a tool like pm2, nodemon or Bun's built-in watch mode.