{"id":16269,"library":"wattpm","title":"Watt, The Node.js Application Server","description":"Watt (wattpm) is Platformatic's core Node.js application server, currently at version 3.52.2. It provides a robust runtime environment for centrally managing and orchestrating multiple Node.js applications, offering built-in support for popular frameworks like Fastify, Next.js, Astro, and Express. The project maintains a very active development cycle, with frequent patch and minor releases, often multiple times a week, ensuring quick bug fixes and feature enhancements. Key differentiators include an integrated virtual mesh network for inter-service communication, high-performance logging via Pino, comprehensive monitoring with Prometheus, and distributed tracing through OpenTelemetry. This makes it suitable for modular monoliths and microservices architectures where centralized management and observability are critical.","status":"active","version":"3.52.2","language":"javascript","source_language":"en","source_url":"https://github.com/platformatic/platformatic","tags":["javascript"],"install":[{"cmd":"npm install wattpm","lang":"bash","label":"npm"},{"cmd":"yarn add wattpm","lang":"bash","label":"yarn"},{"cmd":"pnpm add wattpm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core component for running individual services orchestrated by Watt.","package":"@platformatic/service"},{"reason":"Core component for managing multiple services in a Platformatic Runtime environment.","package":"@platformatic/runtime"},{"reason":"Provides fast logging capabilities (Pino) integrated into the server.","package":"@platformatic/logger"}],"imports":[{"note":"The primary programmatic entry point for launching the Watt server with a configuration. ESM is preferred for Node.js >=22.19.0 environments.","wrong":"const { start } = require('wattpm')","symbol":"start","correct":"import { start } from 'wattpm'"},{"note":"While `wattpm` exports a `start` function, its most common interaction pattern for developers is via the command-line interface (CLI) to scaffold new projects or manage existing ones. Direct programmatic imports for creation functionality are not exposed.","wrong":"import { create } from 'wattpm'","symbol":"Watt CLI","correct":"npx wattpm@latest create"},{"note":"Watt orchestrates services and runtimes. While `wattpm` itself doesn't export many types for its core runtime, developers often import types like `PlatformaticService` or `PlatformaticRuntime` from their respective `@platformatic/*` packages when building Platformatic applications.","symbol":"Platformatic Types","correct":"import type { PlatformaticService } from '@platformatic/service'"}],"quickstart":{"code":"import { start } from 'wattpm';\nimport { writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nasync function bootstrap() {\n  const configPath = join(process.cwd(), 'platformatic.service.json');\n  const config = {\n    server: {\n      hostname: '127.0.0.1',\n      port: 0 // Assigns a random available port\n    },\n    service: {\n      openapi: {\n        url: '/documentation'\n      },\n      routes: {\n        '/hello': {\n          get: {\n            handler: '$.hello'\n          }\n        }\n      }\n    },\n    plugins: {\n      paths: [\n        join(process.cwd(), 'plugin.js')\n      ]\n    }\n  };\n\n  writeFileSync(configPath, JSON.stringify(config, null, 2));\n  writeFileSync(join(process.cwd(), 'plugin.js'), `\n    async function plugin(app) {\n      app.get('/hello', async (request, reply) => {\n        return { message: 'Hello from Watt!' };\n      });\n    }\n    export default plugin;\n  `);\n\n  console.log('Starting Watt server...');\n  const app = await start({ config: configPath });\n\n  console.log(`Watt server listening on ${app.url}/hello`);\n  console.log('Access documentation at ' + app.url + '/documentation');\n\n  // To stop the server programmatically (e.g., in tests or for graceful shutdown)\n  // await app.close();\n}\n\nbootstrap().catch(err => {\n  console.error('Failed to start Watt server:', err);\n  process.exit(1);\n});","lang":"typescript","description":"This quickstart demonstrates how to programmatically start a Watt server, configure a simple Fastify service with a custom plugin, and expose a '/hello' endpoint, illustrating its core runtime capabilities."},"warnings":[{"fix":"Upgrade your Node.js environment to at least version 22.19.0. Use nvm or your preferred Node.js version manager.","message":"Watt now requires Node.js version 22.19.0 or higher. Running on older Node.js versions will result in startup failures.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure you are on the latest `wattpm` version (3.52.2 or newer) to benefit from patched dependencies. Regularly update your `platformatic` project dependencies.","message":"Multiple dependencies, including `fast-jwt`, `fastify`, and `yaml`, have received security updates. Running older versions exposes applications to known vulnerabilities.","severity":"security","affected_versions":"<3.51.0 (for fast-jwt), <3.45.0 (for fastify/yaml)"},{"fix":"Explicitly configure `server.hostname` in your `platformatic.json` or equivalent configuration file. For example, use `\"server\": { \"hostname\": \"0.0.0.0\" }` to listen on all available network interfaces.","message":"Prior to v3.52.0, the server hostname might have implicitly defaulted to `127.0.0.1` even when unset. This behavior was corrected, and now `server.hostname` must be explicitly set if you expect it to bind to a specific interface or `0.0.0.0` for all interfaces.","severity":"gotcha","affected_versions":"<3.52.0"},{"fix":"Update to `wattpm` version 3.52.2 or newer to ensure correct V8 heap sizing for child processes. Review any custom Node.js flags for child processes to avoid conflicts.","message":"Incorrect calculation of `--max-semi-space-size` for child processes in earlier versions could lead to suboptimal memory usage or stability issues in applications relying on multiple worker threads.","severity":"gotcha","affected_versions":"<3.52.2"},{"fix":"Ensure your application logic correctly handles read-only entities when interacting with database views. Verify that write operations are not attempted on view-based entities.","message":"Database views are now supported as read-only entities. While a new feature, if existing code implicitly assumed all database entities were writable and interacted with views, it might lead to unexpected read-only errors if not properly handled.","severity":"breaking","affected_versions":">=3.52.2"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Run `npm install` or `pnpm install` in your project root to ensure all `@platformatic/*` dependencies are correctly installed. Verify your `package.json` for `wattpm` and its peer dependencies.","cause":"One of Watt's core dependencies, such as @platformatic/service or @platformatic/runtime, is missing or incorrectly installed.","error":"Error: Cannot find module '@platformatic/service'"},{"fix":"Explicitly set `server.hostname` to a valid string (e.g., `'127.0.0.1'` or `'0.0.0.0'`) in your `platformatic.json` or `platformatic.service.json` configuration file.","cause":"The `server.hostname` in your Platformatic configuration is either missing or set to an invalid type, especially after the fix in v3.52.0 where implicit defaults were changed.","error":"Error: `server.hostname` option must be a string"},{"fix":"Ensure your application is configured as a `platformatic service` and that plugins exporting Fastify routes are correctly specified in your `platformatic.json` or similar configuration under the `plugins` section. Verify the `app` object in your plugin is indeed a Fastify instance.","cause":"This error typically occurs if you are trying to use Fastify-specific methods directly on an application instance that hasn't been properly initialized as a Platformatic Service or if a plugin isn't correctly registered.","error":"TypeError: app.get is not a function"}],"ecosystem":"npm"}