npm的安装时间失败,出现“找不到”错误


153

当我尝试在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

请更新此帖子以显示您正在使用的操作系统。当前答案对Ubuntu有效,但是,如果您明确了操作系统类型,它将对其他人有用。
2014年

在Angular 7项目上进行npm安装时,这里同样存在问题。
masterxilo

Answers:


454

您正在使用哪个操作系统?

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

$ sudo apt-get install build-essential

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


1
我在MAC OS上也遇到了同样的问题,能否请您指导我如何为MAC设置它。
学习者2014年

@Learner我相信您可能需要安装XCode。它应包含在OS X上编译本机模块所需的所有工具,类似于Ubuntu上的build-essential。
2014年

之所以解决了这个问题,是因为缺少了“ make”程序,而build-essential软件包将其与其他几种构建工具(如g ++)一起安装,如果您要采用这种方法,则需要使用该工具来编译节点。至少对于OP中未提及的OS,应将其标记为答案。
拉斐尔·安东尼奥·普利特

我也有后安装摩西的东西build-essential,我也跟着这太问题之后,终于得到了它安装 stackoverflow.com/questions/32919589/...
菲利普·萨比诺

1
这解决了我在Ubuntu 17.04上的问题。谢谢朱利安!
劳埃德·伊拉斯


12

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

RUN yum install -y make gcc*

为我完美地工作!


1
我想你只是为我节省了很多时间。谢谢!我尝试了一下,gcc*但没有成功。CENTOS 7
法案

1
非常感谢,距此帖子已超过2年。它挽救了我的一天!
Kousick Shanmugam Nagaraj

1
yum list gcc* | wc -l 打印出来, 69 因此要安装很多东西,我建议让构建失败并找出缺少的命令/工具,然后运行yum provides以获取软件包名称,然后进行安装。对我来说,我只需要安装make gcc-c++(分别用于帐户makeg++命令)
Bo Chen

7

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

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


0

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

sudo pacman -S make gcc
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.