-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module '@libsql/darwin-arm64' in standalone build #10484
Comments
Hello, just a fix that worked for me ... import path from 'path'
import { fileURLToPath } from 'url'
import { withPayload } from '@payloadcms/next/withPayload'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
/** @type {import('next').NextConfig} */
const nextConfig = {
// Your Next.js config here
output: 'standalone',
outputFileTracingRoot: path.join(__dirname, '../../'),
outputFileTracingIncludes: {
'/admin/*': [
'../../node_modules/@libsql/**/*',
],
},
}
export default withPayload(nextConfig) my root .npmrc in my monorepo:
my dockerfile in my payload subdirectory (using pnpm for a monorepo) FROM node:22.12.0-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS builder
WORKDIR /app
COPY . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run --filter=cms build
FROM base AS runner
WORKDIR /app
RUN apk add bash
ENV NODE_ENV="production"
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/apps/cms/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/cms/.next/static /app/apps/cms/.next/static
USER nextjs
ENV PORT 3000
EXPOSE $PORT
CMD HOSTNAME="0.0.0.0" node apps/cms/server.js
Now why does this work?
|
Thanks a lot! This works for me in my monorepo setup too. Since this issue is related to Next.js itself, and it happens even in a standalone build without PayloadCMS being integrated, this can be closed here. EDIT:
Otherwise, the API routes will not be able to resolve that module. |
node server.js▲ Next.js 15.1.4
✓ Starting...
|
15.1.4 |
Describe the Bug
Hi,
I am trying to get a standalone build working with
@payloadcms/db-sqlite
. However, neither running the build natively nor using a container with the provided Dockerfile template works for me. For example, when I attempt to access the initial/admin/create-first-user
route after starting the native build, I encounter the following error:I have also tried including
@libsql/client
andlibsql
as project dependencies, as previously mentioned in #7527, it did not resolve the issue for me. Upon inspecting thenode_modules
directory in the resulting build, I noticed that the prebuilt binary package for@libsql
is missing. This leads me to suspect that the issue might be related to the standalone bundling process in Next.js.@DanRibbens
Link to the code that reproduces this issue
https://github.com/janeumnn/payload-reproduction-bug
Reproduction Steps
cd payload-reproduction-bug && pnpm install
.pnpm build
.cp -r .next/static .next/standalone/.next/
.node server.js
.Which area(s) are affected? (Select all that apply)
db-sqlite
Environment Info
The text was updated successfully, but these errors were encountered: