0

I have the exact same error which says

at bindings (/node_modules/pg-native/node_modules/libpq/node_modules/bindings/bindings.js:76:44)  

This might seem similar to:
Error: Module did not self-register.
but the difference being, I am using docker to build images, so it will not be possible for me to go back and remove node_modules and perform npm install again for every container.
Is there a more elegant solution?

Community
  • 1
  • 1
raviabhiram
  • 671
  • 2
  • 8
  • 21

2 Answers2

0

One of the advantages of Docker is that it should be easy to upgrade your images and replace your containers. If you have a bunch of Node apps which all start from the same image:

FROM node

Then you just need to rebuild your images and they will use the latest version of the Node base image (which currently has NPM 3.10.3). In a non-production environment, just stop your container and run a new one from the new image. In production, look at rolling upgrades in swarm mode.

Ideally you should be working towards an automated workflow where you commit a change, that builds a new image and replaces your running container. You shouldn't need to do any maintenance on running containers - they are meant to be disposable.

Elton Stoneman
  • 17,906
  • 5
  • 47
  • 44
  • Thanks Elton. I figured the solution was to do a rebuild after installing node with `npm rebuild` and that fixed the errors. – raviabhiram Oct 04 '16 at 05:27
0

I was getting this error when I ran docker-compose. Also, in my docker-compose I was mounting the current folder. To fix this issue I rebuilt my node modules with npm rebuild.

raviabhiram
  • 671
  • 2
  • 8
  • 21
  • Although docker appeared to make your problem distinct, the canonical thread [Uncaught Error: Module did not self-register](https://stackoverflow.com/questions/28486891/uncaught-error-module-did-not-self-register), has the same [top answer](https://stackoverflow.com/a/28859693/6243352), `npm rebuild`. For future visitors, it may be a good idea to visit that thread if this doesn't resolve the issue. – ggorlen Aug 25 '23 at 15:01