im trying to make a dockerfile and run my code into this container. im getting following error:
node:internal/modules/cjs/loader:1187
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: /node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1187:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
code: 'ERR_DLOPEN_FAILED'
}
My application works fine without docker.
i also tryed to remove bcrypt like in this question: Node – was compiled against a different Node.js version using NODE_MODULE_VERSION 51
dockerfile:
FROM node:16
WORKDIR ./
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 4000
CMD ["node", "server.js"]
.dockerignore:
node_modules
upload
export
converage
.git
.tmp
.vscode
.github
.env
2
Answers
You need to add a
.dockerignore
The basic
.dockerignore
look likeYou should try to delete node_modules. This helped me.