17
votes

I am getting this error when running an example from OpenCV Node

  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: /home/sunny/face/build/opencv/v5.0.0/Release/node-v46-linux-x64/opencv.node: undefined symbol: _ZNK2cv9Algorithm5writeERNS_11FileStorageE
    at Error (native)
    at Object.Module._extensions..node (module.js:460:18)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object. (/home/sunny/face/lib/bindings.js:4:15)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
6

6 Answers

9
votes

Use this command, it works fine:

npm rebuild bcrypt --build-from-source
28
votes

Try refreshing your installed modules by

$ rm -rf node_modules/
$ npm update

I got errors relating to process.dlopen when using Gulp and node-sass. Clearing the installed modules fixed the issue for me.

EDIT: Not certain how OpenCV works (or what it actually is), but I presume it handles NodeJS modules similarly to regular NodeJS applications, where you can refresh the module collection.

2
votes

You should check your OpenCV installation, it's probably either missing/can't be found or its not a version supported by the OpenCV node binding. Assuming you're using the opencv module on npm, its readme says that OpenCV versions from v2.3.1 until v3.0.0 are (fully) supported.

1
votes

My case, I have the node_modules on my .dockerignore

node_modules
upload
export
converage
.git
.tmp
.vscode
.github
.env

But I still have to make docker-compose be able to ignore the node_modules folder.

services:
  api:
    build: .
    command: npm run dev
    volumes:
      - '.:/usr/src/app'
      - /usr/src/app/node_modules/
    ports:
      - "3000:3000"

I think docker-compose will skip copy node_modules which is built for MacOS into Linux container.

Add a volume to Docker, but exclude a sub-folder

1
votes

I had the same issue and it turns out docker is running linux and bcrypt was made on macOS and there is some sort of compatibility issue if you don't run npm install within docker.

For me adding a .dockerignore file and adding in the node_module folders for the project then running RUN npm install in the Dockerfile resolved it.

0
votes

I ran these commands but to no success

$ rm -rf node_modules/
$ npm update

The only thing that helped me was

yarn add node-sass

Finally my node modules were installed successfully.