Next.js Discord

Discord Forum

Error when deploying app

Answered
American Sable posted this in #help-forum
Open in Discord
American SableOP
I'm currently trying to deploy my nextjs+ payload app to Digital Ocean.

At first it failed at build, saying i needed to install sharp.

After installing sharp I'm now getting the error
An error occurred in next/font.
Error: Cannot find module '../lightningcss.linux-x64-musl.node'

I'm at a loss, feels like I've tried everything
Answered by American Sable
I figured it out!

For some I had to include these four optionDependencies to my package.json

`
  "optionalDependencies": {
    "@tailwindcss/oxide-linux-arm64-musl": "^4.0.1",
    "@tailwindcss/oxide-linux-x64-musl": "^4.0.1",
    "lightningcss-linux-arm64-musl": "^1.29.1",
    "lightningcss-linux-x64-musl": "^1.29.1"
  }


I'm using an alpine based docker image, so i chose the musl versions of the dependecies.

After including these everything built as intended
View full answer

5 Replies

American SableOP
Here is my dockerfile

`
FROM node:20-alpine

# Install required dependencies for lightningcss
RUN apk add --no-cache libc6-compat

# Expose the port
EXPOSE 3000

# Set the working directory 
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm install

# Install lightningcss with exact platform version
RUN npm install lightningcss

# Copy the rest of the application code
COPY . .

# Run Payload migrations
RUN npm run payload migrate:create

# Build the application
RUN npm run build

# Start the application
CMD ["npm", "run", "start"]
American SableOP
I figured it out!

For some I had to include these four optionDependencies to my package.json

`
  "optionalDependencies": {
    "@tailwindcss/oxide-linux-arm64-musl": "^4.0.1",
    "@tailwindcss/oxide-linux-x64-musl": "^4.0.1",
    "lightningcss-linux-arm64-musl": "^1.29.1",
    "lightningcss-linux-x64-musl": "^1.29.1"
  }


I'm using an alpine based docker image, so i chose the musl versions of the dependecies.

After including these everything built as intended
Answer
American SableOP
Yeah, litreally said to myself.. Last attempt. If it does not work im going to vercel
Chum salmon
😂 👍