首页 > 解决方案 > 通过 NPM 安装 nsfw 失败,缺少 node_api.h

问题描述

我有一个 Angular 10/Electron 10 项目,并尝试安装nsfw (node-sentinel-file-watcher)。

在安装过程中,我收到以下错误:

$ npm i nsfw
[...]
[...]
> node-gyp rebuild
  CXX(target) Release/obj.target/nsfw/src/NSFW.o
In file included from ../src/NSFW.cpp:1:
In file included from ../src/../includes/NSFW.h:7:
/Users/foo/Desktop/bar/node_modules/node-addon-api/napi.h:4:10: fatal error: 'node_api.h' file not found
#include <node_api.h>
         ^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/nsfw/src/NSFW.o] Error 1
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:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)

我可以在这里找到文件:

/usr/local/include/node/node_api.h
/System/Volumes/Data/Users/foo/.electron-gyp/9.0.4/include/node/node_api.h
/System/Volumes/Data/Users/foo/.electron-gyp/9.1.0/include/node/node_api.h
/System/Volumes/Data/Users/foo/.electron-gyp/9.1.1/include/node/node_api.h
/System/Volumes/Data/Users/foo/.electron-gyp/10.0.0-beta.14/include/node/node_api.h
/System/Volumes/Data/Users/foo/Library/Caches/node-gyp/14.5.0/include/node/node_api.h
/System/Volumes/Data/Users/foo/Library/Caches/node-gyp/12.18.2/include/node/node_api.h
/System/Volumes/Data/Users/foo/Library/Caches/node-gyp/9.1.0/include/node/node_api.h

谁能帮助我并指出我在这里可能想念的东西?

标签: node.jsnpmnpm-install

解决方案


推荐阅读