[GH-ISSUE #734] [Bug] Dockerfile.lite deps stage missing pnpm rebuild sharp causes ERR_MODULE_NOT_FOUND crash on startup #349

Closed
opened 2026-10-20 17:27:53 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Gunterlie on GitHub (May 12, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/734

Originally assigned to: @Romuromylus on GitHub.

Summary

Marinara Engine crashes on startup with ERR_MODULE_NOT_FOUND: Cannot find package 'sharp'
when using a self-built Dockerfile.lite image. Sharp is declared as an optional dependency
but is required at runtime — causing it to be dropped by --no-optional in the deps stage
and leaving the production image without the sharp binary.

Expected behavior

Container starts successfully. Sharp native binary is available at runtime and sprite
generation + background removal work as expected.

Actual behavior

Container exits immediately on startup with:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sharp' imported from
/app/packages/server/dist/routes/game-assets.routes.js
Node.js v24.15.0

Steps to reproduce

  1. Clone the repository on any host
  2. Build: docker build --no-cache -f Dockerfile.lite -t marinara-engine:lite .
  3. Run the container
  4. Container crashes immediately — sharp module not found

Environment

  • Marinara Engine version: latest main (post sharp builder-stage fix)
  • Install type: docker (lite image, self-built)
  • OS + version: Debian 12 (LXC on Proxmox)
  • Hardware: Intel J5005 (CPU-only)

Logs, screenshots, or video

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sharp' imported from
/app/packages/server/dist/routes/game-assets.routes.js
    at Object.getPackageJSONURL (node:internal/modules/package_json_reader:301:9)
    at packageResolve (node:internal/modules/esm/resolve:764:81)
Node.js v24.15.0

Additional context

Root cause: The deps stage installs with --no-optional --ignore-scripts:

pnpm install --frozen-lockfile --prod --no-optional --ignore-scripts

Sharp is declared as an optional dependency in packages/server/package.json,
so --no-optional drops it entirely. Since sprite generation and background
removal depend on sharp at runtime, this declaration is incorrect.

Workaround that confirmed working (removes --no-optional from deps stage):

pnpm install --frozen-lockfile --prod --ignore-scripts && pnpm rebuild sharp

Proper fix: Move sharp from optionalDependencies to dependencies in
packages/server/package.json. This keeps --no-optional working correctly
to exclude onnxruntime and other heavy optional packages, while ensuring sharp
is always present at runtime.

Note: The previous changelog entry "Fixed Lite Docker sprite generation by rebuilding
the sharp native module" only addressed the builder stage. The deps stage was missed
because the root cause (sharp incorrectly marked as optional) was not identified.

Related: #572, #596

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Gunterlie on GitHub (May 12, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/734 Originally assigned to: @Romuromylus on GitHub. ## Summary Marinara Engine crashes on startup with `ERR_MODULE_NOT_FOUND: Cannot find package 'sharp'` when using a self-built Dockerfile.lite image. Sharp is declared as an optional dependency but is required at runtime — causing it to be dropped by `--no-optional` in the deps stage and leaving the production image without the sharp binary. ## Expected behavior Container starts successfully. Sharp native binary is available at runtime and sprite generation + background removal work as expected. ## Actual behavior Container exits immediately on startup with: ``` Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sharp' imported from /app/packages/server/dist/routes/game-assets.routes.js Node.js v24.15.0 ``` ## Steps to reproduce 1. Clone the repository on any host 2. Build: `docker build --no-cache -f Dockerfile.lite -t marinara-engine:lite .` 3. Run the container 4. Container crashes immediately — sharp module not found ## Environment - Marinara Engine version: latest main (post sharp builder-stage fix) - Install type: docker (lite image, self-built) - OS + version: Debian 12 (LXC on Proxmox) - Hardware: Intel J5005 (CPU-only) ## Logs, screenshots, or video ``` Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sharp' imported from /app/packages/server/dist/routes/game-assets.routes.js at Object.getPackageJSONURL (node:internal/modules/package_json_reader:301:9) at packageResolve (node:internal/modules/esm/resolve:764:81) Node.js v24.15.0 ``` ## Additional context **Root cause:** The deps stage installs with `--no-optional --ignore-scripts`: ```dockerfile pnpm install --frozen-lockfile --prod --no-optional --ignore-scripts ``` Sharp is declared as an optional dependency in `packages/server/package.json`, so `--no-optional` drops it entirely. Since sprite generation and background removal depend on sharp at runtime, this declaration is incorrect. **Workaround that confirmed working** (removes `--no-optional` from deps stage): ```dockerfile pnpm install --frozen-lockfile --prod --ignore-scripts && pnpm rebuild sharp ``` **Proper fix:** Move sharp from `optionalDependencies` to `dependencies` in `packages/server/package.json`. This keeps `--no-optional` working correctly to exclude onnxruntime and other heavy optional packages, while ensuring sharp is always present at runtime. Note: The previous changelog entry "Fixed Lite Docker sprite generation by rebuilding the sharp native module" only addressed the builder stage. The deps stage was missed because the root cause (sharp incorrectly marked as optional) was not identified. Related: #572, #596 ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:27:53 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Romuromylus commented on GitHub (May 12, 2026):

Checking

<!-- gh-comment-id:4429104082 --> @Romuromylus commented on GitHub (May 12, 2026): Checking
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#349
No description provided.