Node.js
Posit Connect can run Express, Fastify, and other Node.js HTTP servers. Before publishers deploy Node.js content, an administrator must enable Node.js support. See the Node.js section of the Admin Guide for setup instructions, supported versions, and platform requirements.
Deploying
Use the rsconnect command from the rsconnect-python package (version 1.29.0 or later) to deploy Node.js content.
Terminal
rsconnect deploy nodejs -n myServer ./MyAppPath/The bundle directory must contain both package.json and package-lock.json. Connect installs the production dependencies from package-lock.json during the environment build.
Entry point
The entry point is the JavaScript or TypeScript file that starts your HTTP server. rsconnect-python auto-detects the entry point from package.json in this order:
The
mainfield.The
scripts.startfield, when it follows the patternnode <file>.A common filename in the bundle root:
app.js,index.js,server.js, ormain.js, including their.tsequivalents.
To deploy from a different file, pass --entrypoint:
Terminal
rsconnect deploy nodejs -n myServer --entrypoint src/server.js ./MyAppPath/TypeScript
Connect runs TypeScript entry points natively without a build step. Deploy your .ts entry point directly.
Example
A minimal Express API:
app.js
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
const host = process.env.HOST || '127.0.0.1';
app.get('/', (req, res) => {
res.json({ message: 'Hello from Posit Connect' });
});
app.listen(port, host);package.json
{
"name": "my-express-app",
"version": "1.0.0",
"main": "app.js",
"engines": {
"node": ">=22.18.0"
},
"dependencies": {
"express": "^4.18.0"
}
}Run the following to deploy:
Terminal
npm install
rsconnect deploy nodejs -n myServer ./Listening address
Connect sets HOST to the address where the application must listen and sets both PORT and CONNECT_SERVER_PORT to the assigned port. Pass both values to your server:
app.js
app.listen(process.env.PORT, process.env.HOST);Do not override HOST with 0.0.0.0. Doing so prevents the application from starting in an IPv6-only execution environment. Omitting the host lets Node.js choose a platform default, which might also expose more interfaces than Connect selected when the content-session TLS proxy is enabled.