opsdocsConsole

Packages / ops-env

Nuxt and Nitro

Preload ops-env in a Nuxt or Nitro server, and ship it in an image whose node_modules is not beside the server.

Updated 13 Oct 2026View as Markdown

Use the preload for a Nuxt or Nitro server, never a server plugin:

sh
node --import @syncronet/ops-env/register .output/server/index.mjs

Nitro reads NUXT_* and NITRO_* into its runtime config when its config loads, which is before any server plugin runs. A plugin that calls load() is too late for those keys, and NUXT_PUBLIC_OPS_URL or a private key overridden by NUXT_<KEY> would keep the value from the build.

In an image

--import resolves a bare package name from the working directory. Nitro's .output carries only what the server imports, so in a slim image the package is usually not beside the server. Copy its built files into the image and name the file instead:

dockerfile
COPY --from=build /app/node_modules/@syncronet/ops-env/dist /srv/ops-env
CMD ["node", "--import", "/srv/ops-env/register.js", ".output/server/index.mjs"]

The package ships plain JavaScript in dist, because Node does not strip TypeScript types from files under node_modules.