Skip to content

Commit 9827634

Browse files
committed
fix: Explicitly set node path for npm/npx launchers and shebangs
1 parent f522621 commit 9827634

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ RUN set -ex && \
4444
# Extract and install
4545
mkdir -p /usr/local/node && \
4646
tar -xJf "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" --strip-components=1 -C /usr/local/node && \
47-
# Create symlinks
47+
# Rewrite shebangs to avoid /usr/bin/env (BuildKit/QEMU arm64-safe)
48+
sed -i '1 s|^#!.*|#!/usr/local/node/bin/node|' /usr/local/node/lib/node_modules/npm/bin/npm-cli.js && \
49+
sed -i '1 s|^#!.*|#!/usr/local/node/bin/node|' /usr/local/node/lib/node_modules/npm/bin/npx-cli.js && \
4850
ln -sf /usr/local/node/bin/node /usr/local/bin/node && \
4951
# Provide npm/npx launchers without /usr/bin/env (buildx/QEMU arm64-safe)
5052
printf '%s\n' '#!/bin/sh' \
51-
'exec node /usr/local/node/lib/node_modules/npm/bin/npm-cli.js "$@"' \
52-
> /usr/local/bin/npm && chmod +x /usr/local/bin/npm && \
53+
'exec /usr/local/node/bin/node /usr/local/node/lib/node_modules/npm/bin/npm-cli.js "$@"' \
54+
> /usr/local/bin/npm && chmod +x /usr/local/bin/npm && \
5355
printf '%s\n' '#!/bin/sh' \
54-
'exec node /usr/local/node/lib/node_modules/npm/bin/npx-cli.js "$@"' \
55-
> /usr/local/bin/npx && chmod +x /usr/local/bin/npx && \
56+
'exec /usr/local/node/bin/node /usr/local/node/lib/node_modules/npm/bin/npx-cli.js "$@"' \
57+
> /usr/local/bin/npx && chmod +x /usr/local/bin/npx && \
5658
# Verify installation
5759
node --version && \
5860
npm --version && \

0 commit comments

Comments
 (0)