I'm trying to build an image of my node application but upon execution it shows the error.
PS C:\Users\vallabh\Desktop\visits> docker build .
[+] Building 3.8s (5/5) FINISHED
[internal] load build definition from Dorkerfile
=> transferring Dockerfile! 31B
=> [internal] load .dockerignore
=> => Transferring context: 2B
=> [internal] load metadata for docker.io/library/node:alpine
=> CACHED [1/2] FROM docker.io/library/node:alpine@sha256 :0677e437543016F6cb058d92792a14e5eb84348e3d5b4
> ERROR [2/2] RUN npm install:
The exact error is:
------
> [2/2] RUN npm install:
#5 1.745 npm ERR! Tracker "idealTree" already exists
#5 1.748
#5 1.748 npm ERR! A complete log of this run can be found in:
#5 1.748 npm ERR! /root/.npm/_logs/2022-05-28T07_47_19_509Z-debug-0.log
------
executor failed running [/bin/sh -c npm install]: exit code: 1
PS C:\Users\vallabh\Desktop\visits> executor failed running [/bin/sh -c npm install]: exit code: 1D
How can I avoid this npm install error?
For illustration:

Including the node version in the Dockerfile worked for me:
FROM node:19.5.0-alpine
Check first if you have a similar issue as in here:
This issue is happening due to changes in NodeJS starting with version 15.
When no
WORKDIRis specified,npm installis executed in the root directory of the container, which is resulting in this error.Executing the
npm installin a project directory of the container specified byWORKDIRresolves the issue.
In your case, make sure to set WORKDIR to where your node app resides in your image that you are building.
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