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.
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:
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"
},
npm ci
or npm install
with --include=optional
, example:- name: Install dependencies
run: npm ci --include=optional
Removing package-lock.json
and running npm install
did the trick for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With