skip to Main Content

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:

error

3

Answers


  1. 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 WORKDIR is specified, npm install is executed in the root directory of the container, which is resulting in this error.

    Executing the npm install in a project directory of the container specified by WORKDIR resolves the issue.

    In your case, make sure to set WORKDIR to where your node app resides in your image that you are building.

    Login or Signup to reply.
  2. i have included node version in Dokerfile. worked for me

    FROM node:19.5.0-alpine
    
    Login or Signup to reply.
  3. 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-

    1. Remove my node modules folder

      sudo rm -r node_modules

    2. install node modules again

      npm i

    3. re-run the docker start command

      docker-compose up –build

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search