本文介绍: 我在给nodejs 项目安装依赖包的时候,报了如下错误然后再去安装依赖可以了。

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

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

解决方案:

# CentOS 系统
sudo yum update
sudo yum install gcc-c++

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

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

原文地址:https://blog.csdn.net/fth1002853070/article/details/134662433

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_4631.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注