Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

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

like image 491
Vishwa Vallabh Avatar asked Dec 30 '25 10:12

Vishwa Vallabh


2 Answers

Including the node version in the Dockerfile worked for me:

FROM node:19.5.0-alpine
like image 140
Amar Avatar answered Jan 02 '26 08:01

Amar


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.

like image 24
VonC Avatar answered Jan 02 '26 06:01

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!