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 node-gyp@9.1.0
gyp info using node@18.9.1 | 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++

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

相关推荐
IT果果日记12 分钟前
ubuntu 安装 conda
linux·ubuntu·conda
Python私教14 分钟前
ubuntu搭建k8s环境详细教程
linux·ubuntu·kubernetes
羑悻的小杀马特27 分钟前
环境变量简介
linux
小陈phd1 小时前
Vscode LinuxC++环境配置
linux·c++·vscode
运维&陈同学1 小时前
【zookeeper01】消息队列与微服务之zookeeper工作原理
运维·分布式·微服务·zookeeper·云原生·架构·消息队列
是阿建吖!1 小时前
【Linux】进程状态
linux·运维
明明跟你说过2 小时前
Linux中的【tcpdump】:深入介绍与实战使用
linux·运维·测试工具·tcpdump
Komorebi.py3 小时前
【Linux】-学习笔记05
linux·笔记·学习
Mr_Xuhhh3 小时前
重生之我在学环境变量
linux·运维·服务器·前端·chrome·算法
内核程序员kevin6 小时前
TCP Listen 队列详解与优化指南
linux·网络·tcp/ip