You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FROM node:20
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm ci --omit=dev
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "node", "server.js" ]
Hi, I'm also facing the same issue. I'm using M1 Mac. I'm observing this issue since last week. I have tried Node 20,18 alpine, slim and latest. The issue persist.
I was able to run yarn and npm commands now after disabling Use Rosetta for x86/amd64 emulation on Apple Silicon option in docker settings. Not sure this is a fix.
I'm encountering the same issue - docker build hangs on RUN npm install. The problem occurs when trying to build an image using --platform=linux/amd64 on Docker Desktop Mac.
(Why do this? I want to test an image on my mac laptop that will eventually run in an amd64 environment, and one apt dependency does not have an arm64 version)
Workarounds I found:
Downgrade to the previous base node image (node:18.17.0, should be the case for node:20 as well)
My workaround at the moment is to stay on Node 18.x.
I hope there will be a fix for the armv6 and armv7 architectures. Otherwise I will have to drop them.
Maybe Node 22.x
It seems that this is a duplicate of #1798? I see the same seqence of mremap as reported in #1798 (comment) when using strace with the reproducer from #1946 (comment).
What triggered this problem for me was updating my package-lock.json from version 1 to version 3.
Solution
The key solution for me was using npm install --no-audit, which also just makes it run much faster, and auditing can probably just be done independently of the normal build/CI process.
Details
Here are some additional details I gathered before finding the final solution, in case it's helpful for others, or for debugging the root problem.
Sorta Solutions
These attempts somewhat worked but not in a satisfactory way...
Reverting back to my version 1 package-lock.json file worked, but I didn't want to stick with this because it felt fragile and it was slow because npm had to recreate it each time I ran my docker-based build (unless in the docker cache).
For 1 code repository, it worked to remove the package-lock.json file and recreate it, but this didn't work for my other repo.
Non-Solutions
These attempts didn't work...
Flushing docker state with ...
docker container prune -a
docker rm -f $(docker ps -qa)
docker image prune -a
docker volume prune
docker volume rm $(docker volume ls -q)
docker buildx prune
apt-cache madison docker-ce
va=... # pick an older version from above
apt-cache madison containerd.io
vb=... # pick an older version from above
apt-get install docker-ce=$va containerd.io=$vb
# restarted
Installing the latest LTS node currently 20.11.1 which contains npm version 10.2.4
Deleting and recreating my package-lock.json (although it worked for the 1 repo mentioned above)
Using docker build --network=host
Reacted by Štěpán Rožník, Patrick Brophy and Jason Qiu
There may be other conditions that also cause npm install to hang, but this is the one that I've most consistently ran into and is doesn't seem related to the node version. Maybe a bug in QEMU?
Any plans to fix this issue? I migrated my Kubernetes cluster to use ARM-based nodes instead of AMD-based nodes, and I cannot deploy my Node-based applications anymore because of this.
Activity
dannykruitbosch commentedon Aug 10, 2023
I have the same issue with yarn
matteovivona commentedon Aug 14, 2023
Same here. My image works with Node 16, 18 and 19. With 20 even
corepack enablecommand gets stuckUpdate: on my pipeline based on Ubuntu-22.04 linux/amd64 works
LaurentGoderre commentedon Sep 14, 2023
I just tried on Ventura with an M2 chip and it didn't hang
LaurentGoderre commentedon Sep 14, 2023
I am ablwe to reproduce the behavior when disabling my network. I am wondering if some firewall rule might be blocking traffic.
callmemaxi commentedon Sep 25, 2023
Hi, I'm also facing the same issue. I'm using M1 Mac. I'm observing this issue since last week. I have tried Node 20,18 alpine, slim and latest. The issue persist.
callmemaxi commentedon Sep 25, 2023
I was able to run yarn and npm commands now after disabling Use Rosetta for x86/amd64 emulation on Apple Silicon option in docker settings. Not sure this is a fix.
eric-zeng commentedon Sep 25, 2023
I'm encountering the same issue - docker build hangs on
RUN npm install. The problem occurs when trying to build an image using--platform=linux/amd64on Docker Desktop Mac.(Why do this? I want to test an image on my mac laptop that will eventually run in an amd64 environment, and one apt dependency does not have an arm64 version)
Workarounds I found:
Dockerfile
package.json
index.js
Console output
will3942 commentedon Oct 2, 2023
Same issue affecting npm and yarn when using
docker buildxand building for linux/arm/v7ozbillwang commentedon Nov 15, 2023
got same issues , you can easily duplicate this issue with below commands
Then it stucks at installation forever.
run tests on below platforms
linux/amd64,linux/arm64/v8,linux/ppc64lebuildxhangs on problem:linux/s390x,inux/arm/v6,linux/arm/v7pheiduck commentedon Dec 3, 2023
My workaround at the moment is to stay on Node 18.x.
I hope there will be a fix for the
armv6andarmv7architectures. Otherwise I will have to drop them.Maybe Node 22.x
n0rt0nthec4t commentedon Dec 12, 2023
Also have the same issue, and reverted back to Node 18.x for my docker builds.
agners commentedon Jan 3, 2024
It seems that this is a duplicate of #1798? I see the same seqence of
mremapas reported in #1798 (comment) when usingstracewith the reproducer from #1946 (comment).omaraboumrad commentedon Jan 15, 2024
Upgrading from Docker Desktop 4.21 to 4.26.1 (Latest at the time of this writing) seems to have fixed this problem for me on an M2 Mac.
fix: arm ci/cd build with node20
brianbraunstein commentedon Mar 20, 2024
Trigger
What triggered this problem for me was updating my
package-lock.jsonfrom version 1 to version 3.Solution
The key solution for me was using
npm install --no-audit, which also just makes it run much faster, and auditing can probably just be done independently of the normal build/CI process.Details
Here are some additional details I gathered before finding the final solution, in case it's helpful for others, or for debugging the root problem.
Sorta Solutions
These attempts somewhat worked but not in a satisfactory way...
Reverting back to my version 1
package-lock.jsonfile worked, but I didn't want to stick with this because it felt fragile and it was slow because npm had to recreate it each time I ran my docker-based build (unless in the docker cache).For 1 code repository, it worked to remove the
package-lock.jsonfile and recreate it, but this didn't work for my other repo.Non-Solutions
These attempts didn't work...
Installing the latest LTS
nodecurrently 20.11.1 which containsnpmversion 10.2.4Deleting and recreating my
package-lock.json(although it worked for the 1 repo mentioned above)Using
docker build --network=host52 remaining items
kaaax0815 commentedon Feb 7, 2025
Sorry. Was a typo. I was using
pnpmthe whole wayEdit: nvm I was using npm, but why does it only in GitHub actions. Building it locally works fine.
In the second stage there is no pnpm as I only normally copy build results. So using npm should be fine
pipex commentedon Feb 7, 2025
In my testing this only happens when running a musl Node build in an emulated environment, for instance my platform does not support armv7 natively
Adding emulated support
Now, the following works
But the following hangs forever
There may be other conditions that also cause
npm installto hang, but this is the one that I've most consistently ran into and is doesn't seem related to the node version. Maybe a bug in QEMU?kaaax0815 commentedon Feb 10, 2025
I can confirm the problem pipex has on a mac m1 pro.
It worked once, but after a uninstall and reinstall of binfmt it stopped working again. This is very weird
himself65 commentedon Mar 3, 2025
same issue with
FROM --platform=linux/amd64 node:22.4-bookwormfeat(Dockerfile): use node v22.14 LTS
feat(Dockerfile): use node v22.14 LTS
MedAzizTousli commentedon Apr 9, 2025
Any plans to fix this issue? I migrated my Kubernetes cluster to use ARM-based nodes instead of AMD-based nodes, and I cannot deploy my Node-based applications anymore because of this.
Lazerbeak12345 commentedon Apr 9, 2025
There's more than one issue here. It no longer happens for me on the latest version of all involved packages, and I haven't had it happen in months.
If you can recreate it in a Docker container, providing a Docker file may help the maintainers debug this.
EDIT: There is a dockerfile provided above. Guess debugging is the next step.
lyswhut commentedon Apr 10, 2025
As far as I tested, it is still not solved now
You can reproduce it with the following
Dockerfile,console.log(1)will hang:Koenkk commentedon Apr 15, 2025
Seems to be finally fixed now (run)!
tyranron commentedon Apr 17, 2025
Yes, for
linux/arm/v7andlinux/arm/v6now runs OK. Still hangs, though, onlinux/s390x.chore: Upgrade to Node.js 22
Lazerbeak12345 commentedon Oct 10, 2025
MikeMcC399 commentedon May 3, 2026
Closing as stale, since Node.js 20 reached end-of-life on 2026-04-30.
The remark in #1946 (comment) about
linux/s390xsounds like a emulation issue that can't be fixed here, since this repo does not supply emulation.Other remarks indicate that the initial issue may no longer be a problem in general.