npm无法安装make not found错误

pet*_*ter 118 node.js

当我尝试在nodejs服务器上安装时间时,我得到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

Jul*_*que 383

你在使用哪种操作系统?

如果是Ubuntu,你需要安装build-essential软件包:

$ sudo apt-get install build-essential
Run Code Online (Sandbox Code Playgroud)

然后尝试再次安装包.

  • 答案对于Ubuntu操作系统是正确的. (7认同)
  • 此解决方案适用于debian (2认同)

Sha*_*pta 11

简单解决方案

sudo apt-get install build-essential
Run Code Online (Sandbox Code Playgroud)

然后再试一次


Mar*_*les 8

我在使用Docker时遇到了同样的问题,包括CENTOS 7和RHEL 7基础映像......执行以下操作:

RUN yum install -y make gcc*
Run Code Online (Sandbox Code Playgroud)

为我工作完美!

  • `yum 列表 gcc* | wc -l ` 打印 `69 ` 所以需要安装很多东西,我建议让构建失败并找出缺少哪个命令/工具,然后您可以运行 `yumprovides` 来获取包名称,然后安装它。对我来说,我只需要安装`make gcc-c++`(分别代表`make`和`g++`命令) (3认同)

ake*_*lec 8

如果您使用的是 Windows 和 npm,请通过 cmd(管理员)安装:

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


Rem*_*der 8

对于阿尔卑斯山:

apk --no-cache add build-base
Run Code Online (Sandbox Code Playgroud)

如果 gyp 也需要 python,请添加以下内容:

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
Run Code Online (Sandbox Code Playgroud)

(也许这有点过头了,但在我们的例子中它成功了)

在 a 中Dockerfile,前缀apkRUN 并替换exportENV,如下所示:

RUN apk --no-cache add build-base
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

该软件包build-base的描述如下:https: //pkgs.alpinelinux.org/package/v3.17/main/x86/build-base 基本上没有自己的内容,但依赖于binutilsfortify-headersg++gcc和。libc-devmake


小智 5

对于 Manjaro/Arch Linux,您需要安装 make 和 gcc

sudo pacman -S make gcc
Run Code Online (Sandbox Code Playgroud)