Error: Error loading shared library /home/node/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: Exec format error
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1206:18)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Object.require.extensions.
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.
2020-08-19T12:52:14: PM2 log: App [access-backend:0] exited with code [1] via signal [SIGINT]
2020-08-19T12:52:16: PM2 log: [Watch] Stop watching access-backend
2020-08-19T12:52:16: PM2 log: PM2 successfully stopped
FROM keymetrics/pm2:12-alpine
RUN mkdir -p /app
WORKDIR /app
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
COPY package*.json ./
RUN npm cache clean --force && rm -rf node_modules && npm install
EXPOSE 7777
CMD [ "pm2-runtime", "start", "ecosystem.config.js" ]
+1
I have the same problem
+1
Please do not copy node_modules inside Docker. It decreases your build time and prevents this kind of errors from happening.
Use a .dockerignore and add node_modules/ to it
Did anyone solve this problem?
Adding node_modules to .dockerignore solved this.
docker is not detecting changes in the layers above "run npm ..." therefore it does not build the complete image. I solved it by exchanging run position with copy
I was having the same issue. Fixed by uninstalling bcrypt before building with docker, then adding bcrypt back to package.json. When you build with docker after adding bcrypt back to package.json, it should complete with no errors.
Most helpful comment
Please do not copy
node_modulesinside Docker. It decreases your build time and prevents this kind of errors from happening.Use a
.dockerignoreand addnode_modules/to it