CentOS 系统给nodejs 项目安装依赖报错 make: g++: No such file or directory

我在给nodejs 项目安装依赖包的时候,报了如下错误

bash 复制代码
error /var/www/bsrm-api/node_modules/sleep: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /var/www/bsrm-api/node_modules/sleep
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 3.9.9 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/var/www/bsrm-api/node_modules/sleep/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.cache/node-gyp/18.9.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/18.9.1',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/18.9.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/var/www/bsrm-api/node_modules/sleep',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/var/www/bsrm-api/node_modules/sleep/build'
  CXX(target) Release/obj.target/node_sleep/module_init.o
make: g++: No such file or directory
make: *** [node_sleep.target.mk:116: Release/obj.target/node_sleep/module_init.o] Error 127
make: Leaving directory '/var/www/bsrm-api/node_modules/sleep/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201:23)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 5.10.0-60.70.0.94.oe2203.bclinux.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/bsrm-api/node_modules/sleep
gyp ERR! node -v v18.9.1

有一个这个错误:
make: g++: No such file or directory

解决方案:

bash 复制代码
# CentOS 系统
sudo yum update
sudo yum install gcc-c++

# Ubuntu 系统
sudo apt-get update
sudo apt-get install g++

然后再去安装依赖就可以了。

相关推荐
孙克旭_2 小时前
PXE_Kickstart_无人值守自动化安装系统
linux·运维·自动化
皓月盈江3 小时前
Linux电脑本机使用小皮面板集成环境开发调试WEB项目
linux·php·web开发·phpstudy·小皮面板·集成环境·www.xp.cn
深井冰水3 小时前
mac M2能安装的虚拟机和linux系统系统
linux·macos
leoufung4 小时前
内核内存锁定机制与用户空间内存锁定的交互分析
linux·kernel
π大星星️4 小时前
HAProxy + Keepalived + Nginx 高可用负载均衡系统
运维·nginx·负载均衡
IT专业服务商5 小时前
联想 SR550 服务器,配置 RAID 5教程!
运维·服务器·windows·microsoft·硬件架构
忧虑的乌龟蛋5 小时前
嵌入式Linux I2C驱动开发详解
linux·驱动开发·嵌入式·iic·i2c·读数据·写数据
I_Scholar6 小时前
OPENSSL-1.1.1的使用及注意事项
linux·ssl
Johny_Zhao6 小时前
K8S+nginx+MYSQL+TOMCAT高可用架构企业自建网站
linux·网络·mysql·nginx·网络安全·信息安全·tomcat·云计算·shell·yum源·系统运维·itsm
稳联技术7 小时前
Ethercat转Profinet网关如何用“协议翻译术“打通自动化产线任督二脉
linux·服务器·网络