安装节点软件包时发生问题,node-gyp重建

时间:2019-01-06 07:31:02

标签: npm npm-install node-gyp

我有点像Node的初学者,但是一段时间以来我一直在使用discord.js开发一个discord机器人。我想将其托管在AWS的EC2服务器上。但是,当我尝试sudo npm install安装软件包时,会得到以下提示:

ubuntu@ip-172-31-33-102:~$ sudo npm install

> ref@1.3.5 install /home/ubuntu/node_modules/ref
> node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/ubuntu/node_modules/ref/build'
gyp ERR! System Linux 4.15.0-1021-aws
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ubuntu/node_modules/ref
gyp ERR! node -v v11.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

> node-opus@0.3.1 install /home/ubuntu/node_modules/node-opus
> node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/ubuntu/node_modules/node-opus/build'
gyp ERR! System Linux 4.15.0-1021-aws
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ubuntu/node_modules/node-opus
gyp ERR! node -v v11.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN discord.js@11.4.2 requires a peer of bufferutil@^3.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of uws@^9.14.0 but none is installed. You must install peer dependencies yourself.
npm WARN enmap@4.5.0 requires a peer of better-sqlite-pool@github:eslachance/better-sqlite-pool but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ref@1.3.5 (node_modules/ref):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ref@1.3.5 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-opus@0.3.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-opus@0.3.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2019-01-06T07_12_30_305Z-debug.log

最后一行提到的日志是here

我环顾四周,尽管人们遇到类似的问题,但所有修复方法均无效。

如果需要,该机器人的完整代码为here。 我只需要知道如何解决此错误,即可安装软件包。 谢谢。

1 个答案:

答案 0 :(得分:1)

如果有人通过谷歌(像我一样)在这里找到这个问题的答案: 就我而言,它缺少“g++”库。

sudo apt-get install g++

帮我搞定了。