TooTallNate/node-bindings

Will not check local directory for build

Closed this issue · 1 comments

I have a project structure similar to something like this:

root/
|-- bin/
|-- src/
|-- scripts/
     |-- build/
     |-- src/
     |-- binding.gyp
     |-- run.js

Where scripts/src/ has my .cpp files for my node addon, and when I configure and build my addon, it gets compiled built into the scripts/build/ directory.

My run.js file looks like this:

'use strict';

require('bindings')('addon.node');

Whenever I try to run my run.js file, bindings isn't able to find my addon.node because it is checking my root directory instead of the local directory which has the actual build file:

Error: Could not locate the bindings file. Tried:
 → C:\~projects\root\build\addon.node
 → C:\~projects\root\build\Debug\addon.node
 → C:\~projects\root\build\Release\addon.node
 → C:\~projects\root\out\Debug\addon.node
 → C:\~projects\root\Debug\addon.node
 → C:\~projects\root\out\Release\addon.node
 → C:\~projects\root\Release\addon.node
 → C:\~projects\root\build\default\addon.node
 → C:\~projects\root\compiled\4.1.2\win32\x64\addon.node

I tried changing require('bindings')('addon.node'); to absolute paths, but bindings still tries to search the root directory instead of the local directory where my build directory is located.

Is this a bug in the program or am I approaching this / doing something wrong?

I solved this issue by reading the source code of node-gyp and realizing that it will search the first directory it finds with a package.json. This should be specified in the documentation.