NUXT Build Error Cannot find module @oxc-parser/binding-linux-x64-gnu

After upgrading to Nuxt 4.3.x, I'm getting a some errors in my GitHub Actions. Here's what’s happening:

#13 0.388 bun install v1.3.9 (cf6cdbbb)
#13 6.192 
#13 6.192 $ nuxt prepare
#13 6.898 
#13 6.898  ERROR  Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try npm i again after removing both package-lock.json and node_modules directory.
#13 6.898
#13 6.898     at node_modules/oxc-transform/index.js:575:15
#13 6.898     at moduleEvaluation (native:1:11)
#13 6.898     at moduleEvaluation (native:1:11)
#13 6.898     at requestImportModule (native:2)
#13 6.898     at processTicksAndRejections (native:7:39)
#13 6.898
#13 6.898   [cause]: Cannot find module '@oxc-transform/binding-linux-x64-gnu' from '/app/node_modules/oxc-transform/index.js'
#13 6.898
#13 6.898
#13 6.898     [cause]: Cannot find module './transform.linux-x64-gnu.node' from '/app/node_modules/oxc-transform/index.js'
#13 6.898
#13 6.917 error: postinstall script from "nuxt-app" exited with 1
#13 ERROR: process "/bin/sh -c BUN_POSTINSTALL=enable bun install --frozen-lockfile" did not complete successfully: exit code: 1
------
 > [install 3/3] RUN BUN_POSTINSTALL=enable bun install --frozen-lockfile:
6.898     at processTicksAndRejections (native:7:39)
6.898
6.898   [cause]: Cannot find module '@oxc-transform/binding-linux-x64-gnu' from '/app/node_modules/oxc-transform/index.js'
6.898
6.898
6.898     [cause]: Cannot find module './transform.linux-x64-gnu.node' from '/app/node_modules/oxc-transform/index.js'
6.898
6.898
6.898
6.917 error: postinstall script from "nuxt-app" exited with 1
------
Dockerfile:11
--------------------
   9 |     COPY package.json bun.lock ./
  10 |     COPY . .
  11 | >>> RUN BUN_POSTINSTALL=enable bun install --frozen-lockfile
  12 |
  13 |     # Copy project files into the image
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c BUN_POSTINSTALL=enable bun install --frozen-lockfile" did not complete successfully: exit code: 1

Here this is my current package,json

After researching, I found that Nuxt uses Vite under the building

  • esbuild for transforming and transpiling in the dev server
  • For production builds, Vite has been using Rollup from the start and will change to Rolldown, a full Rust rewrite designed to be compatible with the Rollup API
    - The main reason: Rollup is written mainly in JavaScript, making it still slow for large projects
    - Rollup v4 has already started migrating parts of its parser to SWC (written in Rust)
  • Several native libraries are also gradually moving to Rust, such as: oxc-parser/binding-linux-x64-gnu / oxc-minify/binding-linux-x64-gnu / tailwindcss/oxide-linux-x64-gnu

However, container base images like Alpine use musl libc instead of glibc, making these native bindings incompatible out of the box. The fix is to declare them as optionalDependencies, so the package manager gracefully skips installation when the platform doesn't match, rather than throwing an error and halting the entire build.

Here is my update package,json with optionalDependencies

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.