Reputation: 1550
I had a working Dockerfile until literally a day ago when it just seemed to break. I didn't make any changes to my dependencies - but I am getting the following error:
[91mnpm ERR! code ENOGIT
[0m
[91mnpm ERR! No git binary found in $PATH
npm ERR!
npm[0m
[91m ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.
[0m
[91m
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-09-28T21_12_50_050Z-debug.log
[0m
Removing intermediate container be9d5bfe5521
The command '/bin/sh -c npm install' returned a non-zero code: 1
This is super strange because this wasn't happening before. I'm also attaching my Dockerfile. The things I've tried so far are adding git (third line), and also trying to export the path. Nothing seems to be working.
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y git
FROM node:alpine
RUN npm install sails -g
#RUN npm install git -g
#RUN export PATH="$HOME/usr/bin/git:$PATH"
RUN mkdir -p /service/app
WORKDIR /service/app
COPY package.json /service/app
RUN npm install
COPY . /service/app
EXPOSE 80
CMD NODE_ENV=production sails lift
Upvotes: 4
Views: 6493
Reputation: 12395
I know this was an old question but I noticed none of the answers addressed the root cause of your problem even though adding RUN apk add git
can fix it in the end.
In your Dockerfile, you have two FROM, but apparently, you did not use it them for Multi-stage builds, which means you did it wrong. Your adding git clause has no use there (your first from related clauses have no use too.).
Adding git clause should be added to the second from clause, FROM node:alpine
and for alpine, it should use apk add
not apt-get install
(that is for ubuntu)
Upvotes: 0
Reputation: 136
I had the same issue. It was due to lack of git. Below is how it worked
FROM node:alpine
RUN apk add git
RUN npm install ...
Upvotes: 2
Reputation: 622
Try the following:
RUN apk update && \
apk add --update git && \
apk add --update openssh
The git binary within the docker container becomes available at /usr/bin/git
Upvotes: 1
Reputation: 3661
One reason for this could be that you are using the slim version of node in your Dockerfile
:
FROM node:8-slim
I presume this does not include git, because when I changed to the full version the error went away:
FROM node:8.11.2
Upvotes: 3