简体   繁体   English

错误:模块未自行注册

[英]Error: Module did not self register

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. 但是不同之处在于,我正在使用docker构建映像,因此我将无法返回并删除node_modules并为每个容器再次执行npm install。
Is there a more elegant solution? 有没有更优雅的解决方案?

One of the advantages of Docker is that it should be easy to upgrade your images and replace your containers. Docker的优点之一是应该很容易升级映像并更换容器。 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 ). 然后,您只需要重建映像,它们将使用最新版本的Node基本映像(当前具有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. 您不需要对运行中的容器进行任何维护-它们是一次性的。

I was getting this error when I ran docker-compose. 运行docker-compose时出现此错误。 Also, in my docker-compose I was mounting the current folder. 另外,在我的docker-compose中,我正在安装当前文件夹。 To fix this issue I rebuilt my node modules with npm rebuild . 为了解决这个问题,我使用npm rebuild重建了我的节点模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM