# Node.js Server Applications

> Deploy @txtextcontrol/tx-sheet-control-server: Node.js 22, the complete package in node_modules, bundlers and container images, fonts and destroy() per job.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Deployment Guide > Node.js Server Applications
- **1197 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/deployment/nodejs/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/deployment/nodejs/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/deployment/nodejs/llms-full.txt

---

The Node.js server package, `@txtextcontrol/tx-sheet-control-server`, processes workbooks without a browser. It finds its engine and its fonts inside its own folder in `node_modules`, so a deployment must contain the installed package complete. It does not need the editor package, a browser or a network connection.

### Requirements and Module Formats

- **Node.js 22 or newer**, as the `engines` field of the package requires.
- **ES modules and CommonJS.** The package provides both entry points: `import { ServerSheetControl } from '@txtextcontrol/tx-sheet-control-server'` and `require('@txtextcontrol/tx-sheet-control-server')`. TypeScript finds the type declarations through the same package name.

### Deploy the Installed Package

Deploy `node_modules/@txtextcontrol/tx-sheet-control-server` complete, about 85 MB: its `dist` folder contains the engine, the runtime files and the `fonts` folder with the 30 supplied families and their notices. The package archive is not in the npm registry, so the build or the deployment installs it from the archive in your repository, as [Install the npm Packages](https://docs.textcontrol.com/tx-sheet-control/installation/npm/llms-full.txt) describes.

> Warning
>
> **Complete Package.** Do not copy only a JavaScript file of the package. The package loads further files from its folder at run time.

### Use a Bundler

A bundler such as esbuild, webpack or Rollup must leave the package out of the bundle and load it from `node_modules` at run time. Bundled in, it fails at the first control with `Cannot find module '…/private/runtime.cjs'`. Mark it as external, for example with esbuild:

```bash
esbuild job.mjs --bundle --platform=node --format=esm --external:@txtextcontrol/tx-sheet-control-server --outfile=dist/job.mjs
```

Then deploy the bundle together with `node_modules/@txtextcontrol/tx-sheet-control-server`.

### Build a Container Image

In a container image, install the dependencies inside the image and copy the application next to them, so that `node_modules/@txtextcontrol/tx-sheet-control-server` is complete:

```dockerfile
FROM node:22-slim
WORKDIR /app
COPY package.json package-lock.json ./
COPY vendor ./vendor
RUN npm ci --omit=dev
COPY . .
CMD ["node", "job.mjs"]
```

`COPY vendor ./vendor` copies the package archive, which `package.json` references, before `npm ci` installs it. Pass the license as the environment variable `TX_SHEET_LICENSE` when you start the container, not in the image.

### Fonts

The package uses the fonts in its `dist/fonts` folder. To add fonts, copy that folder, add your files and set the [fontDirectory](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/serversheetcontroloptions/fontdirectory-property/llms-full.txt) option or the environment variable `TX_SHEET_FONT_DIRECTORY` to the copy, as [Custom Fonts](https://docs.textcontrol.com/tx-sheet-control/deployment/custom-fonts/llms-full.txt) shows. [getFontCatalog()](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/getfontcatalog-method/llms-full.txt) lists the families found. Fonts installed on the computer are not used.

### Manage the Lifetime of Each Job

A [ServerSheetControl](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/llms-full.txt) holds a workbook and its processing state. Create one per independent job, await loading and saving, and release it with [destroy()](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/destroy-method/llms-full.txt) in `finally`:

```javascript
import { ServerSheetControl, StreamType } from '@txtextcontrol/tx-sheet-control-server';

const control = new ServerSheetControl();
try {
    control.workbook.sheets.at(0).cell('A1').setText('Quarterly report');
    const pdf = await control.save(StreamType.PDF);
} finally {
    control.destroy();
}
```

A control that you reuse for unrelated requests must load a clean document for each of them. Limit the number of jobs that run at the same time, and stop a job with the `signal` option of `load` and `save` when its request is canceled.

### Verify the Deployment

Run a job from the final deployment folder or container image, with the license it uses in production: load an XLSX file, calculate a formula and save a PDF with several pages. A successful `import` alone does not prove that the engine and the fonts are deployed.

### Next Steps

- [Node.js tutorial](https://docs.textcontrol.com/tx-sheet-control/getting-started/document-processing/nodejs/llms-full.txt): set up a first Node.js processing application.
- [Backend Services](https://docs.textcontrol.com/tx-sheet-control/document-processing/backend-services/llms-full.txt): create reports without a browser and return them in HTTP responses.
- [Deployment Problems](https://docs.textcontrol.com/tx-sheet-control/deployment/problems/llms-full.txt): fix engine, font and license errors after the deployment.

---

## Nearby

- **Previous:** [.NET Server Applications](https://docs.textcontrol.com/tx-sheet-control/deployment/dotnet/llms-full.txt)
- **Next:** [Host Security and File Handling](https://docs.textcontrol.com/tx-sheet-control/deployment/security/llms-full.txt)
