Node.js
Built with npm, with the Node.js version it asks for.
On this page
Moorage builds Node.js apps with npm, with the Node.js version the project asks for, and runs the start script — or serves the build's output as a static site when there is none.
The app#
{
"name": "hello",
"private": true,
"scripts": {
"start": "node server.js"
},
"engines": { "node": ">=22" }
}// server.js
const http = require("node:http");
http
.createServer((req, res) => res.end(req.url === "/healthz" ? "ok" : "hello from Node.js"))
.listen(Number(process.env.PORT), "127.0.0.1");A build script, if there is one (tsc, vite build…), runs after the install.
Commit package-lock.json (npm install makes it). A moorage.toml is optional:
[app]
name = "hello"
[processes.web]
health = { path = "/healthz" }Deploy#
moor manifest explainmoor deployHow it builds#
- Node.js version:
.nvmrc, or else.node-version, or elseengines.node, or else the current LTS release;[node].versionoverrides them. Partial versions (24) and ranges (>=22,^22.1,24.x,lts/*) are resolved to the newest matching release (a>=range prefers LTS releases). - Dependencies:
npm ci(ornpm install, with a warning, without a lockfile), then thebuildscript if there is one ([node].build_scriptnames another), thennpm prune --omit=dev([node].prune = falsekeeps development dependencies). pnpm, yarn and bun are not available yet; to use one installed on the server, set[build].commandandtoolchains = ["pnpm@system"]under[app]. node_modules/.bincomes first onPATH, and npm's cache is shared between builds.
Running it#
- The
startscript runs directly — not throughnpm start— so that the stop signal reaches the app.NODE_ENV=productionis set. - Without a
startscript, the build'sdist/,build/orout/(the first with anindex.html) is served as a static site, with the rules of[static](see static sites): single-page apps setspa = true.
A complete app: the Poll example, an Express API with a Vite front end.