fatal error: 'functional' file not found #include <functional>
when i compile, i failed.
node-libsecurity/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not found
#include
version: node-addon-api: 1.2.0 system: macos 10.13.2 node: v9.2.1
Make sure you have Xcode Command Line tools installed. <functional> is a system header (well, a STL header.)
@bnoordhuis xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates
@bnoordhuis My node addon is written with c, but not c++.
The functional is in the following dir, but i can not reference it.
"/Library/Developer/CommandLineTools/usr/include/c++/v1/"
if i add the dir into the "include_dirs":of gyp file.
errors occur :
bogon:lib snowdream$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn /usr/bin/python
gyp info spawn args [ '/Users/snowdream/.nvm/versions/node/v9.2.1/lib/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 '/Users/snowdream/workspace/snowdream/node-libsecurity/lib/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/snowdream/.nvm/versions/node/v9.2.1/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/snowdream/.node-gyp/9.2.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=/Users/snowdream/.node-gyp/9.2.1',
gyp info spawn args '-Dnode_gyp_dir=/Users/snowdream/.nvm/versions/node/v9.2.1/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/snowdream/.node-gyp/9.2.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/snowdream/workspace/snowdream/node-libsecurity/lib',
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 make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
SOLINK_MODULE(target) Release/nothing.node
CC(target) Release/obj.target/security/binding.o
In file included from ../binding.c:5:
In file included from /Users/snowdream/workspace/snowdream/node-libsecurity/node_modules/node-addon-api/napi.h:5:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/functional:483:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:387:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:44:
/Library/Developer/CommandLineTools/usr/include/c++/v1/__nullptr:55:1: error: unknown type name 'namespace'
namespace std
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__nullptr:55:14: error: expected ';' after top level declarator
namespace std
^
In file included from ../binding.c:5:
In file included from /Users/snowdream/workspace/snowdream/node-libsecurity/node_modules/node-addon-api/napi.h:5:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/functional:483:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:387:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:49:7: error: expected ';' after top level declarator
using ::size_t;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:49:8: error: expected identifier or '('
using ::size_t;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:53:7: error: expected ';' after top level declarator
using ::max_align_t;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:53:8: error: expected identifier or '('
using ::max_align_t;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:58:1: error: unknown type name '_LIBCPP_END_NAMESPACE_STD'
_LIBCPP_END_NAMESPACE_STD
^
In file included from ../binding.c:5:
In file included from /Users/snowdream/workspace/snowdream/node-libsecurity/node_modules/node-addon-api/napi.h:5:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/functional:483:
/Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:393:28: error: expected ';' after top level declarator
_LIBCPP_BEGIN_NAMESPACE_STD
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:396:1: error: unknown type name 'template'
template make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/snowdream/.nvm/versions/node/v9.2.1/lib/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:159:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Darwin 17.3.0
gyp ERR! command "/Users/snowdream/.nvm/versions/node/v9.2.1/bin/node" "/Users/snowdream/.nvm/versions/node/v9.2.1/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/snowdream/workspace/snowdream/node-libsecurity/lib
gyp ERR! node -v v9.2.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
bogon:lib snowdream$
What does xcode-select -p print?
As to the build error, napi.h is a C++ header; use node_api.h in C files.
xcode-select -p /Applications/Xcode.app/Contents/Developer bogon:Developer snowdream$
So what was the solution, @snowdream ? I'm experiencing /node_modules/weak-napi/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not found when trying to install npm install node-addon-api.
I verified the installation using xcode-select -p, deleted package-lock.json, cleaned the npm cache, verified that Node is v18, etc., I visited lots of threads and sites where references the fatal error: 'functional' file not found and can't find the solution. I know this issue is pretty old but wondering if I can get some insights from here.
So what was the solution, @snowdream ? I'm experiencing
/node_modules/weak-napi/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not foundwhen trying to installnpm install node-addon-api.I verified the installation using
xcode-select -p, deletedpackage-lock.json, cleaned the npm cache, verified that Node is v18, etc., I visited lots of threads and sites where references thefatal error: 'functional' file not foundand can't find the solution. I know this issue is pretty old but wondering if I can get some insights from here.
After spending a day trying to fix the same issue I finally managed to do it by reinstalling xcode-select (though the version didn't change).
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
So what was the solution, @snowdream ? I'm experiencing
/node_modules/weak-napi/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not foundwhen trying to installnpm install node-addon-api. I verified the installation usingxcode-select -p, deletedpackage-lock.json, cleaned the npm cache, verified that Node is v18, etc., I visited lots of threads and sites where references thefatal error: 'functional' file not foundand can't find the solution. I know this issue is pretty old but wondering if I can get some insights from here.After spending a day trying to fix the same issue I finally managed to do it by reinstalling
xcode-select(though the version didn't change).sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install
same
So what was the solution, @snowdream ? I'm experiencing
/node_modules/weak-napi/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not foundwhen trying to installnpm install node-addon-api. I verified the installation usingxcode-select -p, deletedpackage-lock.json, cleaned the npm cache, verified that Node is v18, etc., I visited lots of threads and sites where references thefatal error: 'functional' file not foundand can't find the solution. I know this issue is pretty old but wondering if I can get some insights from here.After spending a day trying to fix the same issue I finally managed to do it by reinstalling
xcode-select(though the version didn't change).sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install
same here
this is the way