7 months ago
--Encountered error:
Error: Failed to load native binding at Object. (/app/node_modules/@swc/core/binding.js:333:11)
--Dockerfile build step EDITED
FROM node:20.19.5-alpine3.21 AS build
WORKDIR /app
COPY package*.json ./
ENV npm_config_ignore_scripts=false
ENV npm_config_optional=true
RUN npm ci
COPY . .
RUN npm run build
--package.json
"dependencies": {
"@strapi/plugin-cloud": "5.29.0",
"@strapi/plugin-users-permissions": "5.29.0",
"@strapi/strapi": "5.29.0",
"fs-extra": "^10.0.0",
"mime-types": "^2.1.27",
"pg": "8.8.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^6.0.0",
"strapi-phone-validator-5": "^1.0.0",
"strapi-plugin-multi-select": "^2.1.1",
"styled-components": "^6.0.0",
"@swc/core": "^1.7.26"
}
I am using a node image which should allow for the native binding, and even setting @swc/core as a dependency which should load the compatible library. I am not sure at this point what more I could do.
6 Replies
7 months ago
Hey there! We've found the following might help you get unblocked faster:
- 🧵 Strapi build fail: Failed to load native binding
- 🧵 Unmable to build basic Node project
- 🧵 Guidance for Replit → GitHub → Railway deployments (best practices & handoff checklist)
If you find the answer from one of these, please let us know by solving the thread!
Railway
Hey there! We've found the following might help you get unblocked faster: - [🧵 Strapi build fail: Failed to load native binding](https://station.railway.com/questions/strapi-build-fail-failed-to-load-native-9085c4ec) - [🧵 Unmable to build basic Node project](https://station.railway.com/questions/unmable-to-build-basic-node-project-f5d1349f) - [🧵 Guidance for Replit → GitHub → Railway deployments (best practices & handoff checklist)](https://station.railway.com/community/guidance-for-replit-git-hub-railway-d-743a3b78) If you find the answer from one of these, please let us know by solving the thread!
7 months ago
None of those help
7 months ago
The issue is that Alpine Linux doesn't have the necessary native bindings for @swc/core. The swc bindings are platform specific, and alpine uses musl libc instead of glibc, which can cause native
module issues.
Here are two solutions 👀
Switch to Debian-based Node image
Use the Dockerfile
FROM node:20.19.5 AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
sumon9836devil
The issue is that Alpine Linux doesn't have the necessary native bindings for @swc/core. The swc bindings are platform specific, and alpine uses musl libc instead of glibc, which can cause native module issues. Here are two solutions 👀 Switch to Debian-based Node image Use the Dockerfile FROM node:20.19.5 AS build WORKDIR /app COPY package\*.json ./ RUN npm ci COPY . . RUN npm run build
7 months ago
FROM node:20.19.5 AS build
WORKDIR /app
# Install dependencies
COPY package*.json ./
RUN npm ci
# Build
COPY . .
RUN npm run build
# Remove dev dependencies after build
RUN npm prune --omit=dev
FROM node:20.19.5 AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=1337
# Copy the built app with pruned dependencies
COPY --from=build /app /app
EXPOSE 1337
CMD ["npm", "run", "start"]Still running into the same issue at RUN npm run build when strapi is attempting to build the admin panel
7 months ago
Solution no 2 did make the issue with running the npm run build work, but now I have an issue with Sharp
Could not load js config file /app/node_modules/@strapi/upload/dist/server/index.js: Could not load the "sharp" module using the linux-x64 runtime
7 months ago
Will open another thread for the new sharp issue
Status changed to Solved brody • 7 months ago