While building a docker files i'm getting error executor failed running [/bin/sh -c npm install]: exit code: 1

Viewed 1430

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:

error

1 Answers

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.

Related