2017-07-30 50 views
0

我有一個定製的node.js應用程序在VM中正常運行,但是當我嘗試在docker中運行它時,錯誤docker中的node.js - 無法找到綁定文件.../bcrypt_lib.node

Error initializing middleware 
Error: Could not locate the bindings file. Tried: 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/build/bcrypt_lib.node 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/build/Debug/bcrypt_lib.node 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/build/Release/bcrypt_lib.node 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/out/Debug/bcrypt_lib.node 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/Debug/bcrypt_lib.node 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/out/Release/bcrypt_lib.node 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/Release/bcrypt_lib.node 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/build/default/bcrypt_lib.node 
→ /usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/compiled/4.8.4/linux/x64/bcrypt_lib.node 
    at bindings (/usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/node_modules/bindings/bindings.js:88:9) 
    at Object.<anonymous> (/usr/src/app/node_modules/co-bcrypt/node_modules/bcrypt/bcrypt.js:3:35) 

Dockerfile看起來像下面

FROM node:4-onbuild 

# Create app directory 
WORKDIR /usr/src/app 

# Install app dependencies 
COPY package.json . 
ENV PORT 8080 

RUN npm install 
RUN npm install --unsafe-perm node-gyp 
RUN npm install --unsafe-perm libxmljs 
RUN npm rebuild 

# Bundle app source 
COPY . . 

EXPOSE 8080 
CMD [ "npm", "start" ] 

我已經添加了建議提到here沒有成功(安裝節點GYP和libxmljs,做NPM重建)。我正在使用"bcryptjs": "^2.3.0"

任何建議如何使它的工作表示讚賞! :)

+1

你見過? https://github.com/pilwon/ultimate-seed/issues/54 – Robert

+0

謝謝,是的。我已經做了重建,並使用bcryptjs。但是,多虧了你,我已經完成了整個項目,並找到了根本原因:) co-bcrypt在package.json中存在... –

回答

0

問題的根本原因是使用co-bcrypt。將其從package.json中刪除並將所有要求的語句替換爲bcryptjs後,錯誤消失。