rembrembdocs

Skip to main content

Bun home pagelight logodark logo

[Runtime

](../../../index.md)[Package Manager

](../../../pm/cli/install/index.md)[Bundler

](../../../bundler/index.md)[Test Runner

](../../../test/index.md)[Guides

](../../index.md)[Reference

](https://bun.com/reference)[Blog

](https://bun.com/blog)[Feedback

](../../../feedback/index.md)

PM2 is a popular process manager that manages and runs your applications as daemons (background processes). It offers features like process monitoring, automatic restarts, and scaling. Using a process manager is common when deploying a Bun application on a cloud-hosted virtual private server (VPS), as it:


You can use PM2 with Bun in two ways: as a CLI option or in a configuration file.

[​

](#with-interpreter)

With --interpreter

To start your application with PM2 and Bun as the interpreter, open your terminal and run the following command:

terminal

pm2 start --interpreter ~/.bun/bin/bun index.ts

[​

](#with-a-configuration-file)

With a configuration file

Alternatively, you can create a PM2 configuration file. Create a file named pm2.config.js in your project directory and add the following content.

pm2.config.js

module.exports = {
  name: "app", // Name of your application
  script: "index.ts", // Entry point of your application
  interpreter: "bun", // Bun interpreter
  env: {
    PATH: `${process.env.HOME}/.bun/bin:${process.env.PATH}`, // Add "~/.bun/bin/bun" to PATH
  },
};

After saving the file, you can start your application with PM2

terminal

pm2 start pm2.config.js

That’s it! Your JavaScript/TypeScript web server is now running as a daemon with PM2 using Bun as the interpreter.

Was this page helpful?

Suggest editsRaise issue

[

Build an app with Nuxt and Bun

Previous

](../nuxt/index.md)[

Use Prisma with Bun

Next

](../prisma/index.md)