Skip to content

🐳 fix(docker): add optional dependency for rollup library - linux binary #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MateuszNaKodach
Copy link

Resolves rollup native module missing error on Apple Silicon by adding
@rollup/rollup-linux-arm64-musl as optional dependency.

Before docker-compose --profile app build on Apple Silicon caused:

 => ERROR [app builder  9/10] RUN npm run build                                                                                                                                                                               0.2s
------
 > [app builder  9/10] RUN npm run build:
0.125 
0.125 > [email protected] build
0.125 > tsup
0.125 
0.173 Error: Cannot find module @rollup/rollup-linux-arm64-musl. 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.
0.173     at requireWithFriendlyError (/app/node_modules/rollup/dist/native.js:59:9)
0.173     at Object.<anonymous> (/app/node_modules/rollup/dist/native.js:68:76)
0.173     at Module._compile (node:internal/modules/cjs/loader:1730:14)
0.173     at Object..js (node:internal/modules/cjs/loader:1895:10)
0.173     at Module.load (node:internal/modules/cjs/loader:1465:32)
0.173     at Function._load (node:internal/modules/cjs/loader:1282:12)
0.173     at TracingChannel.traceSync (node:diagnostics_channel:322:14)
0.173     at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
0.173     at Module.require (node:internal/modules/cjs/loader:1487:12)
0.173     at require (node:internal/modules/helpers:135:16)
------
failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

The issue

The Mac (Host): macOS ARM64 (Darwin ARM64)
Docker Container: Linux ARM64 (linux-arm64-musl)
When you run npm install on your Mac, npm installs the rollup binary for macOS ARM64:
@rollup/rollup-darwin-arm64 ✅ (gets installed)
But inside the Docker container, you're running Linux ARM64, which needs a different binary:
@rollup/rollup-linux-arm64-musl ❌ (missing!)

The solution

By adding the optional dependency, we ensure that both binaries are available:
Darwin ARM64 binary (for Mac)
Linux ARM64 binary (for Docker container)
This way, rollup can find the correct binary regardless of whether it's running on your Mac directly or inside a Linux Docker container on your Mac.
The architecture matches (ARM64), but the operating system (Darwin vs Linux) requires different compiled binaries.

…lity

Force linux/amd64 platform to resolve rollup native module issues on ARM64 Macs.
Improves npm install reliability and removes obsolete docker-compose version.
Resolves rollup native module missing error on Apple Silicon by adding
@rollup/rollup-linux-arm64-musl as optional dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant