Add services (like Postgres) as Node dependencies

Add services (like Postgres) as Node dependencies

Angel M Miguel
Angel M Miguel
/ 2025-07-11

Setting up a development environment is one of the first tasks when starting a new software project or contributing to an existing one. This process includes installing a programming language runtime or compiler but also external services like databases or key/value stores.

Most languages come with a standard set of development tools for installing dependencies (such as npm or pip for Node and Python projects respectively). However, there is no standard tooling for setting up third-party dependencies. Docker is probably the closest, but that in turn adds Docker as a pre-requisite for you, your users, and contributors.

Until now. With Endor, you can add services like Postgres, MariaDB, and Valkey to your Node projects as regular npm dependencies. Services start in less than 5 seconds, are fully isolated, and run in any operating system (including Windows) thanks to WebAssembly 🚀.

Run services with Endor

To run these services, first add @endorhq/cli as a development dependency in your project. You might also want to add concurrently to run your project and Endor at the same time.

npm install -D @endorhq/cli concurrently
# or
pnpm add -D @endorhq/cli concurrently

You can check the available applications by running endor:

endor run

This command will output all the available services:

🪐 Select an environment to launch

  alpine • Alpine (ports 2222)
  mariadb • MariaDB database (ports 3306)
  memcached • Memcached cache (ports 11211)
  redis • Redis cache (ports 6379)
  postgres • PostgreSQL database (ports 5432)
  valkey • Valkey cache (ports 6379)

  Example: endor run mariadb

Finally, update your project’s scripts in the package.json file to call endor:

{
	"name": "my-project",
	"version": "0.1.0",
	"type": "module",
	"scripts": {
-		"dev": "node src/index.js",
+		"dev": "concurrently npm:dev:app npm:dev:db",
+		"dev:app": "node src/index.js",
+		"dev:db": "endor run postgres",
		"test": "echo 'No tests yet'"
	},
	"devDependencies": {
		"@endorhq/cli": "^0.1.8",
		"concurrently": "^9.2.0"
	}
}

Endor will start a Postgres instance running on port 5432 with the root user and no password. Now, you only need to set these values as defaults in your project configuration.

Connecting to the Database

Once Endor is running, you can connect to the Postgres database using any Node database client. Here’s an example using the popular pg library:

import pkg from 'pg';
const { Client } = pkg;

const client = new Client({
	host: 'localhost',
	port: 5432,
	user: 'root',
	password: '', // No password required
	database: 'postgres'
});

await client.connect();
console.log('Connected to Postgres!');

The database comes pre-configured and ready to use, so no complex setup required.

You can find a full example app in our @endorhq/node-demo repository.

Developer Experience is Everything

From increasing team productivity to onboarding new contributors, developer experience is critical. The developer dream is simple: download a repository, run a command, work on a new feature, stop it, and have no unused files left behind. A fast and clean environment that’s functional and easy to use.

It’s still far from being perfect, but Endor reduces the gap by setting up common services in an ecosystem you already know. For any developer, on any operating system including Windows.

Do you need a database? Just remember:

npx -y @endorhq/cli run postgres

And you’re ready to go!

Share this article