Requires rebuild after every package install with yarn, multiple bugs in getOpenCV function
Opened this issue · 0 comments
Hi Uriel,
Great work with the library!
I am using yarn and I noticed that whenever I add or remove a package, yarn resets the node_modules package states. This results in the loss of release files and opencv4nodejs requires rebuilding everytime a package install takes place.
Even if I manually copy over the opencv4nodejs.node file to OPENCV_BIN_DIR (as this is the directory the getOpenCV function checks for), it does not work because the function does not look for the correct file path.
From what I could decipher, the getOpenCV function uses the below logic:
-
Looks for
Debug/opencv4nodejs.node
insidenode_modules/@u4/opencv4nodejs/build/
, then looks forRelease/opencv4nodejs.node
inside the same folder -
In case the Release build is not found, it checks for
process.env.path
- this would work only on windows, I think this should beprocess.env.PATH
:Lines 65 to 68 in db49b49
-
Next. it tries to add OPENCV_BIN_DIR to
process.env.path
, I think path should be contactenated with the colon operator on linux and semicolon on windows (unless this part is meant only for windows):Line 77 in db49b49
-
After path modification, it tries to require the exact same release build path it did in Step 1, without any modification to the path - This is guaranteed to fail, are we trying to look for
OPENCV_BIN_DIR/opencv4nodejs.node
instead ofnode_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs.node
at this point?
I am not sure if the above logic is written as it was meant to be. Also, I would highly recommend making the output directory for node-gyp used within the package configurable via an environment variable and using the same environment variable to check for the build files existence in getOpenCV.
Kindly look into this.