error C2039 ‘Buffer’ is not a member of ‘node’

eye-catch JavaScript/TypeScript

When I ran a build for C++ code by node-gyp, the following error occurred.

$ npm run build

> module-name@2.9.14 build D:\development\software-name\src\modules\module-name
> sh

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
D:\development\software-name\src\modules\module-name\node_modules\nan\nan.h(880,13): error C2039: 'Buffer':
 is not a member of 'node' [D:\development\software-name\src\modules\module-name\MyApp\build\MyAppApiModule
C:\Users\user_name\AppData\Local\node-gyp\Cache.16.1\include\node\node_object_wrap.h(29): message : see declaration o
f 'node' [D:\development\software-name\src\modules\module-name\MyApp\build\MyAppApiModule.vcxproj]
D:\development\software-name\src\modules\module-name\node_modules\nan\nan.h(880,13): error C3083: 'Buffer':
 the symbol to the left of a '::' must be a type [D:\development\software-name\src\modules\module-name\MyApp\build\MyAppApiModule.vcxproj]
D:\development\software-name\src\modules\module-name\node_modules\nan\nan.h(880,21): error C2039: 'FreeCall
back': is not a member of 'node' [D:\development\software-name\src\modules\module-name\MyApp\build\MyAppApi

I tried to rebuild node-gyp but it didn’t solve the problem. The problem was that C:\Users\user_name\AppData\Local\node-gyp\Cache\12.16.1\include\node\node_buffer.h was empty for some reason. nan.h includes the file but the build of course fails without the implementation. It must have the implementation but not.

Once I deleted C:\Users\user_name\AppData\Local\node-gyp\Cache folder, the build succeeded again.


Copied title and URL