Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module '@nx/nx-linux-x64-gnu'

I'm trying to run the build of my Angular project using NX in the CI with GitHub Actions, but it fails with errors such as:

npm ERR! code 1
npm ERR! path /runner/_work/myapp/node_modules/nx
npm ERR! command failed npm ERR! command sh -c node ./bin/post-install
npm ERR! /runner/_womyapp/node_modules/nx/src/native/index.js:244
npm ERR!     throw loadError
npm ERR!     ^
npm ERR!
npm ERR! Error: Cannot find module '@nx/nx-linux-x64-gnu'

NX Missing Platform Dependency

The Nx CLI could not find or load the native binary for your supported platform (linux-x64). This likely means that optional dependencies were not installed correctly, or your system is missing some system dependencies. For more information please see https://nx.dev/recipes/troubleshooting/troubleshoot-nx-install-issues

Error: Process completed with exit code 1.

like image 873
Francesco Borzi Avatar asked Sep 08 '25 11:09

Francesco Borzi


2 Answers

There are several suggested solutions on GitHub for this issues, for example deleting node_modules and package-lock.json and regenerating them with npm install, however none of such solutions worked for me.

I finally found the solution pointed out by the user k3nsei which worked for me:

  1. Add the following to your package.json file (replace the 18.0.4 nx version with the one you are using, preferably the latest one):
  "optionalDependencies": {
    "@nx/nx-darwin-arm64": "18.0.4",
    "@nx/nx-darwin-x64": "18.0.4",
    "@nx/nx-linux-x64-gnu": "18.0.4",
    "@nx/nx-win32-x64-msvc": "18.0.4"
  },
  1. In your CI scripts, run the npm ci or npm install with --include=optional, example:
- name: Install dependencies
  run: npm ci --include=optional
like image 151
Francesco Borzi Avatar answered Sep 10 '25 06:09

Francesco Borzi


Removing package-lock.json and running npm install did the trick for me.

like image 23
Nasreddine Avatar answered Sep 10 '25 07:09

Nasreddine