nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.56k stars 2.36k forks source link

NX CLI Docker-Compose Issue: Missing Platform Dependency #21097

Closed BeBo1337 closed 8 months ago

BeBo1337 commented 9 months ago

Current Behavior

Like the title states I am receiving the following error message...

ERROR

In short...I am trying to have some tests on a server(wolverine) that I have written using NestJS, when trying to run docker-compose up wolverine the image and container seem to finish building but then I get: NX Missing Platform Dependency The Nx CLI could not find or load the native binary for your supported platform (linux-x64)

I am using nx v17.2.8 if this is at all relevant...

I have exhausted all the suggestions in the troubleshooting LINK that is attached to the error message.

-Tried deleting node_modules and package-lock.json and running npm install

-Made sure I installed the most recent version of Microsoft Visual C++ Redistributable

-"Confirm that you see @nx/nx-plaform-arch in your node_modules folder (e.g. @nx/nx-darwin-arm64, @nx/nx-win32-x64-msvc, etc).":

[On my windows 10 64 bit PC](https://i.stack.imgur.com/NsezH.png)

On my docker desktop my docker builder is desktop-linux and I have both of the linux-platform-architectures installed on nx

[On the docker](https://i.stack.imgur.com/QgwgP.png)

here is my docker file:

`FROM node:18.16.1-alpine as builder

WORKDIR /home/node

COPY package*.json /home/node/

RUN npm install

COPY . /home/node/

RUN npm run build wolverine

FROM node:18.16.1-alpine as wolverine

WORKDIR /home/app

COPY --from=builder /home/node/dist/apps/wolverine/package*.json /home/app/

COPY --from=builder /home/node/dist/ /home/app/dist/

RUN npm ci --ignore-scripts

RUN apk --no-cache add curl

CMD ["sh", "-c", "node dist/apps/wolverine/main.js"]`

I am really at a lost here to what might cause this issue... Thanks in advance.

Expected Behavior

Expecting it to not get this error and start listening to the configured port.

GitHub Repo

No response

Steps to Reproduce

1.

Nx Report

Node   : 18.16.1
   OS     : win32-x64
   npm    : 9.7.2

   nx (global)        : 17.2.8
   nx                 : 17.2.8
   @nx/js             : 17.2.8
   @nx/jest           : 17.2.8
   @nx/linter         : 17.2.8
   @nx/eslint         : 17.2.8
   @nx/workspace      : 17.2.8
   @nx/devkit         : 17.2.8
   @nx/eslint-plugin  : 17.2.8
   @nx/nest           : 17.2.8
   @nx/node           : 17.2.8
   @nrwl/tao          : 17.2.8
   @nx/webpack        : 17.2.8
   typescript         : 5.2.2

Failure Logs

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.

Package Manager Version

No response

Operating System

Additional Information

No response

BeBo1337 commented 9 months ago

bump?

BeBo1337 commented 9 months ago

Rip. I guess nobody on the internet knows how to use NX

Cammisuli commented 9 months ago

sorry for the delayed response! Based on the screenshot, are you running your application through Nx? (I see nx run wolverine:serve:development, but in your steps in the dockefile, I only see build)

Can you make sure that the working directory that where you're running the serve has a node_modules/@nx/nx-linux-* directory.

BeBo1337 commented 9 months ago

Yes, the nx run wolverine:serve:development command is run on the docker-compose file. I thought asking about a specific microservice might help ease the problem since this problem happenes on every docker container I have....

And yes the directory is on every docker container before it runs the command, yet it still happens.

Cammisuli commented 9 months ago

Can you create a test.js file that has this content:

console.log(
  require('child_process').execSync(
    'find node_modules -name "*.node" | grep -E "(@nx|@nrwl)"  ',
    { encoding: 'utf8' }
  )
);
console.log(require('nx/src/native').hashArray(['hello']));

Put that in your docker image, and run it with node test.js in the exact same directory that you would run the nx command. Then can you give me the output?

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 7 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.