254

When i try to install time on nodejs server i get the below error:

time@0.8.4 install /var/www/track/node_modules/time
node-gyp rebuild
gyp ERR! build error
gyp ERR! stack Error: not found: make
gyp ERR! stack     at F (/usr/lib/nodejs/npm/node_modules/which/which.js:43:28)
gyp ERR! stack     at E (/usr/lib/nodejs/npm/node_modules/which/which.js:46:29)
gyp ERR! stack     at /usr/lib/nodejs/npm/node_modules/which/which.js:57:16
gyp ERR! stack     at Object.oncomplete (fs.js:297:15)
gyp ERR! System Linux 3.2.0-31-virtual
gyp ERR! command "node" "/usr/lib/nodejs/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/track/node_modules/time
gyp ERR! node -v v0.8.15
gyp ERR! node-gyp -v v0.7.1
gyp ERR! not ok
npm ERR! time@0.8.4 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the time@0.8.4 install script.
npm ERR! This is most likely a problem with the time package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls time
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-31-virtual
npm ERR! command "nodejs" "/usr/bin/npm" "install" "time"
npm ERR! cwd /var/www/track
npm ERR! node -v v0.8.15
npm ERR! npm -v 1.1.66
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /var/www/track/npm-debug.log
npm ERR! not ok code 0
Marc Fischer
  • 1,296
  • 1
  • 13
  • 16
peter
  • 3,411
  • 5
  • 24
  • 27
  • 1
    Please update this post to show what OS you are using. The current answer is valid for Ubuntu, however, it would be helpful for others if you clarified your OS type. – Val Sep 23 '14 at 03:31
  • Same problem here while doing npm install on an Angular 7 project. – masterxilo Mar 01 '19 at 19:23

6 Answers6

771

Which OS are you using?

If it's Ubuntu you'll need to install the build-essential package:

$ sudo apt-get install build-essential

Then try to install the package again.

Bob Fanger
  • 28,949
  • 7
  • 62
  • 78
Julián Duque
  • 9,407
  • 1
  • 21
  • 16
  • 1
    I am facing the same problem with MAC OS.Can you please guide me how to set it up for MAC. – Learner Nov 19 '14 at 13:03
  • @Learner I believe you may need to install [XCode](https://itunes.apple.com/us/app/xcode/id497799835?mt=12). It should contain all the tools needed to compile native modules on OS X, similar to build-essential on Ubuntu. – CatDadCode Dec 30 '14 at 17:56
  • This solved the issue because the program 'make' es missing and the build-essential package installs it along with several other build tools like g++ which is needed to compile node if you want to go that route. This should be marked as the answer, at least for the OS which is not mentioned in the OP. – Rafael Antonio Pólit Apr 14 '16 at 02:33
  • 1
    I also had to install mose stuff after `build-essential`, I followed this SO question afterwards and finally got it to install http://stackoverflow.com/questions/32919589/npm-install-mongoose-causes-gyp-and-kerberos-errors-gssapi-gssapi-h-file-not-fo – Felipe Sabino Jul 22 '16 at 21:51
29

I had the same problem using Docker, both on CENTOS 7 and RHEL 7 base images... do the following:

RUN yum install -y make gcc*

Worked perfectly for me!

Note: Instead of installing all 69 packages listed in gcc* you can install only what you need for the install nodejs like below

dnf install -y gcc-c++ make 
mahen3d
  • 7,047
  • 13
  • 51
  • 103
Marcello DeSales
  • 21,361
  • 14
  • 77
  • 80
  • 1
    I guess you just saved me a bunch of time. Thanks! I tried without `gcc*` but it didn't work. CENTOS 7 – Bill Oct 27 '16 at 22:44
  • 3
    `yum list gcc* | wc -l ` prints `69 ` so that's a lot to install I would recommend let the build fail and find out which command/tool is missing, you then can run `yum provides` to get the package name and then install it. for me, I only need to install `make gcc-c++` (which account for `make` and `g++` command respectively) – Bo Chen Apr 01 '18 at 06:05
10

If you are using Windows and npm, install it through cmd (Administrator):

npm install --global --production windows-build-tools

akelec
  • 3,797
  • 3
  • 41
  • 39
6

For Alpine:

apk --no-cache add build-base

In case gyp is also hungry for python, add the following:

export PYTHONUNBUFFERED=1
apk add --update --no-cache python3 \
    && ln -sf python3 /usr/bin/python \
    && python3 -m ensurepip \
    && pip3 install --no-cache --upgrade pip setuptools

(maybe this is overshooting, but in our case it did the trick)

in a Dockerfile, prefix apk with RUN and replace export with ENV, as follows:

RUN apk --no-cache add build-base

and

ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 \
    && ln -sf python3 /usr/bin/python \
    && python3 -m ensurepip \
    && pip3 install --no-cache --upgrade pip setuptools

The package build-base is described here: https://pkgs.alpinelinux.org/package/v3.17/main/x86/build-base and basically just has no own content, but depends on binutils, fortify-headers, g++, gcc, libc-dev and make.

Remigius Stalder
  • 1,921
  • 2
  • 26
  • 31
  • For Alpine, you can also use nikolaik/python-nodejs docker images that ship with a built in python, given that you trust the source – Cyril Duchon-Doris Dec 12 '22 at 15:32
  • does this image also contain the gcc toolchain? some npm modules contain parts that need to be compiled using gcc during installation. – Remigius Stalder Dec 13 '22 at 08:09
  • I still had to install tools to run `make`: `RUN apk --no-cache add build-base` as mentionned in your answer, I'm not sure whether gcc is included in there or not. – Cyril Duchon-Doris Dec 13 '22 at 15:48
5

For Manjaro/Arch Linux you need to install make and gcc

sudo pacman -S make gcc
andiF
  • 91
  • 1
  • 5
0

For anyone getting this error when using Mono docker image, add this in your Dockerfile in addition to other stuff you may have:

FROM mono:latest

RUN apt-get update
RUN apt-get install -y build-essential
...

Basically the same command as in accepted answer.

antisa
  • 945
  • 7
  • 8