I’m trying to build an image of my node application but upon execution it shows the error.
PS C:UsersvallabhDesktopvisits> 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:UsersvallabhDesktopvisits> executor failed running [/bin/sh -c npm install]: exit code: 1D
How can I avoid this npm install
error?
For illustration:
3
Answers
Check first if you have a similar issue as in here:
In your case, make sure to set
WORKDIR
to where your node app resides in your image that you are building.i have included node version in Dokerfile. worked for me
I had this error and none of the above answers helped, the solution provided by ChatGPT helped me in this case, all I needed to do was-
Remove my node modules folder
sudo rm -r node_modules
install node modules again
npm i
re-run the docker start command
docker-compose up –build