Strapi build fail: Failed to load native binding

seemus
PRO

a year ago

Strapi is not building on Railway, builds ok locally. Not sure what the @swc core is but it exists locally.

Any help would be great as this site needs to go live by the weekend!

Here is the build log:

12 0.201 > strapi build

12 2.059 /app/node_modules/@swc/core/binding.js:333

12 2.059 throw new Error('Failed to load native binding', { cause: loadErrors })

12 2.059 ^

12 2.059

12 2.059 Error: Failed to load native binding

12 2.059 at Object. (/app/node_modules/@swc/core/binding.js:333:11)

12 2.059 at Module._compile (node:internal/modules/cjs/loader:1434:14)

12 2.059 at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)

12 2.059 at Module.load (node:internal/modules/cjs/loader:1249:32)

12 2.059 at Module._load (node:internal/modules/cjs/loader:1065:12)

12 2.059 at Module.require (node:internal/modules/cjs/loader:1271:19)

12 2.059 at require (node:internal/modules/helpers:123:16)

12 2.059 at Object. (/app/node_modules/@swc/core/index.js:49:17)

12 2.059 at Module._compile (node:internal/modules/cjs/loader:1434:14)

12 2.059 at Module._extensions..js (node:internal/modules/cjs/loader:1518:10) {

12 2.059 [cause]: [

12 2.059 Error: Cannot find module './swc.linux-x64-gnu.node'

12 2.059 Require stack:

12 2.059 - /app/node_modules/@swc/core/binding.js

12 2.059 - /app/node_modules/@swc/core/index.js

12 2.059 - /app/node_modules/@vitejs/plugin-react-swc/index.cjs

12 2.059 - /app/node_modules/@strapi/pack-up/dist/index.js

12 2.059 - /app/node_modules/@strapi/strapi/dist/commands/actions/plugin/build-command/action.js

12 2.059 - /app/node_modules/@strapi/strapi/dist/commands/actions/plugin/build-command/command.js

12 2.059 - /app/node_modules/@strapi/strapi/dist/commands/index.js

12 2.059 - /app/node_modules/@strapi/strapi/dist/cli.js

12 2.059 - /app/node_modules/@strapi/strapi/bin/strapi.js

12 2.059 at Module._resolveFilename (node:internal/modules/cjs/loader:1186:15)

12 2.059 at Module._load (node:internal/modules/cjs/loader:1012:27)

12 2.059 at Module.require (node:internal/modules/cjs/loader:1271:19)

12 2.059 at require (node:internal/modules/helpers:123:16)

12 2.059 at requireNative (/app/node_modules/@swc/core/binding.js:211:16)

12 2.059 at Object. (/app/node_modules/@swc/core/binding.js:306:17)

12 2.059 at Module._compile (node:internal/modules/cjs/loader:1434:14)

12 2.059 at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)

12 2.059 at Module.load (node:internal/modules/cjs/loader:1249:32)

12 2.059 at Module._load (node:internal/modules/cjs/loader:1065:12) {

12 2.059 code: 'MODULENOTFOUND',

12 2.059 requireStack: [

12 2.059 '/app/node_modules/@swc/core/binding.js',

12 2.059 '/app/node_modules/@swc/core/index.js',

12 2.059 '/app/node_modules/@vitejs/plugin-react-swc/index.cjs',

12 2.059 '/app/node_modules/@strapi/pack-up/dist/index.js',

12 2.059 '/app/node_modules/@strapi/strapi/dist/commands/actions/plugin/build-command/action.js',

12 2.059 '/app/node_modules/@strapi/strapi/dist/commands/actions/plugin/build-command/command.js',

12 2.059 '/app/node_modules/@strapi/strapi/dist/commands/index.js',

12 2.059 '/app/node_modules/@strapi/strapi/dist/cli.js',

12 2.059 '/app/node_modules/@strapi/strapi/bin/strapi.js'

12 2.059 ]

12 2.059 },

12 2.059 Error: Cannot find module '@swc/core-linux-x64-gnu'

12 2.059 Require stack:

12 2.059 - /app/node_modules/@swc/core/binding.js

View Deploy details

> ⓘ Deployment information is only viewable by project members and Railway employees.

Solved

4 Replies

a year ago

It looks like you're missing the unix deps for SWC (which I'm assuming comes from next). What OS are you on ? You might need to customize your build step / package deps to add support for the unix binary


Status changed to Awaiting User Response Railway 11 months ago


seemus
PRO

a year ago

Thanks for the quick response.

Its a Strapi instance which I assume is a react site. Im running it on windows and usually it builds and deploys fine, but I did have to reinstall some packages but not heard of SWC until this error.

Any guidance on how I can customize the build deps?

Thanks again


Status changed to Awaiting Railway Response Railway 11 months ago


seemus
PRO

a year ago

creating the TOML file worked. I also changed the node version but that didnt work until I created the config file as suggested.

Many thanks


a year ago

Perfect - glad to hear you got this running ! lmk if anything else comes up :)


Status changed to Awaiting User Response Railway 11 months ago


Status changed to Solved itsrems 11 months ago


Strapi build fail: Failed to load native binding - Railway Help Station