npm ERR! Tracker “idealTree” already exists

When I try to build a Nodejs application with a Docker file I have received “npm ERR! Tracker “idealTree” already exists” error. I noticed the error with Node version 15.

Here is my Dockerfile.

#Base image name

FROM node:alpine

COPY ./ ./

RUN npm install

#default command

CMD [“npm”,”start”]

And when executing the docker build command I got the below error.

azureuser@Devops-test-vm:~/simpleweb$ docker build .

Sending build context to Docker daemon  4.096kB
Step 1/4 : FROM node:alpine
 ---> 48de5d16038c
Step 2/4 : COPY ./ ./
 ---> aead9d57f1a5
Step 3/4 : RUN npm install
 ---> Running in 4638cdcc19d5
npm notice 
npm notice New minor version of npm available! 7.15.1 -> 7.16.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.16.0>
npm notice Run `npm install -g npm@7.16.0` to update!
npm notice 
npm ERR! Tracker "idealTree" already exists
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-06-05T07_14_16_103Z-debug.log

To fix the error I have added a working directory in the docker file as below.

#Base image name

FROM node:alpine

WORKDIR /usr/app

COPY ./ ./

RUN npm install

#default command

CMD [“npm”,”start”]

And this time the build was successful.

azureuser@Devops-test-vm:~/simpleweb$ docker build .

Sending build context to Docker daemon  4.096kB
Step 1/5 : FROM node:alpine
 ---> 48de5d16038c
Step 2/5 : WORKDIR /usr/app
 ---> Running in 4b1036ca6637
Removing intermediate container 4b1036ca6637
 ---> 5b67d912d96c
Step 3/5 : COPY ./ ./
 ---> 44e1f8d3d92b
Step 4/5 : RUN npm install
 ---> Running in 19aa1fc2b0e7
added 50 packages, and audited 51 packages in 2s

found 0 vulnerabilities
npm notice 
npm notice New minor version of npm available! 7.15.1 -> 7.16.0
npm notice Changelog:<https://github.com/npm/cli/releases/tag/v7.16.0>
npm notice Run `npm install -g npm@7.16.0` to update!
npm notice 
Removing intermediate container 19aa1fc2b0e7
 ---> ade617fbdc94
Step 5/5 : CMD ["npm","start"]
 ---> Running in 127f407ddf7d
Removing intermediate container 127f407ddf7d
 ---> 94504a1b276f
Successfully built 94504a1b276f

Leave a Reply

Your email address will not be published.