218

当我尝试在 nodejs 服务器上安装 time 时,出现以下错误:

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
4

4 回答 4

662

您使用的是哪个操作系统?

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

$ sudo apt-get install build-essential

然后尝试再次安装该软件包。

于 2013-02-08T12:29:56.673 回答
22

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

RUN yum install -y make gcc*

非常适合我!

注意:除了安装 gcc* 中列出的所有 69 个包之外,您可以只安装安装 nodejs 所需的内容,如下所示

dnf install -y gcc-c++ make 
于 2015-06-24T16:56:26.983 回答
9

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

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

于 2018-05-04T10:23:50.043 回答
5

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

sudo pacman -S make gcc
于 2019-03-07T13:13:49.213 回答