Skip to content

How to package nextjs app? #146

Open
@BeyondIM

Description

@BeyondIM

I am using Next.js to build my application with the standalone output mode. When I package it using pkg, everything works fine initially. However, when Next.js generates the full route cache and data cache, it throws an error indicating it cannot create directories under /snapshot. This happens because Next.js tries to write cache files to the .next directory, which is already bundled as static assets during packaging (making it read-only). Since Next.js does not currently support customizing the cache directory path, how can I resolve this issue?

"pkg": {
    "assets": [
      ".next/**/*",
      "public/**/*",
      "node_modules/better-sqlite3/build/Release/better_sqlite3.node"
    ]
  },
  "bin": "./server.js",
cd standalone && pkg . --compress=Brotli -t node20-alpine-x64 -o /app/out/mininav

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions