Meteor run server getting error: "Could not locate the bindings file. [...]bcrypt[...]"

Meteor run server getting error: "Could not locate the bindings file. [...]bcrypt[...]"

问题

我尝试在 Docker 图像中 运行 Meteor 服务器应用程序。 运行启动服务器的主文件出错,详情见下: Could not locate the bindings file.(我的系统:Macbook Pro,OSX 10.11.4)

问题

有人知道如何解决这个错误吗?

尝试解决问题未成功

  1. 运行 npm rebuild 按照建议 here 没有用
  2. 由于 docker 图片中的 root 权限,Nick Bull: Running npm install --unsafe-perm node-gyp and npm install --unsafe-perm libxmljs didn't work. Both executed in the docker container in /home/build/bundle/programs/server. (The --unsafe-perm flag is needed 提出的建议)

详情

  1. Dockerfile(灵感来自meteorhacks/meteord
FROM debian:wheezy

ENV sourcedir /home/source
ENV builddir /home/build
RUN mkdir ${sourcedir} && mkdir ${builddir}

RUN apt-get update -y
RUN apt-get install -y curl bzip2 build-essential python git

RUN \
    NODE_VERSION=4.4.7 \
    && NODE_ARCH=x64 \
    && NODE_DIST=node-v${NODE_VERSION}-linux-${NODE_ARCH} \
    && cd /tmp \
    && curl -O -L http://nodejs.org/dist/v${NODE_VERSION}/${NODE_DIST}.tar.gz \
    && tar xvzf ${NODE_DIST}.tar.gz \
    && rm -rf /opt/nodejs \
    && mv ${NODE_DIST} /opt/nodejs \
    && ln -sf /opt/nodejs/bin/node /usr/bin/node \
    && ln -sf /opt/nodejs/bin/npm /usr/bin/npm

RUN curl -sL https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh

ADD . ${sourcedir}
RUN cd ${sourcedir} \
    && meteor build  --directory ${builddir} --server=http://localhost:3000

RUN cd ${builddir}/bundle/programs/server/ && npm install
  1. 错误消息,当 运行在 bundle 文件夹中 node main.js 时:
/home/build/bundle/programs/server/node_modules/fibers/future.js:280
                        throw(ex);
                        ^

Error: Could not locate the bindings file. Tried:
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/build/bcrypt_lib.node
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/build/Debug/bcrypt_lib.node
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/build/Release/bcrypt_lib.node
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/out/Debug/bcrypt_lib.node
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/Debug/bcrypt_lib.node
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/out/Release/bcrypt_lib.node
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/Release/bcrypt_lib.node
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/build/default/bcrypt_lib.node
 → /home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/compiled/4.4.7/linux/x64/bcrypt_lib.node
    at bindings (/home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bindings/bindings.js:88:9)
    at Object.<anonymous> (/home/build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/bcrypt.js:3:35)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Module.Mp.load (/home/build/bundle/programs/server/npm/node_modules/meteor/babel-compiler/node_modules/reify/node/runtime.js:16:23)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.Npm.require (/home/build/bundle/programs/server/boot.js:190:18)

根据许多 online sources,这是 node-gyp 中的错误。试试这个:

npm install node-gyp
npm install libxmljs

看看会发生什么。

好的,我发现了错误: 问题是 Dockerfile 中环境变量 buildir 的定义: ENV builddir /home/build bcrypt 的构建过程似乎使用相同的变量,并在该目录中构建文件 bcrypt_lib.nodeobj.target。所以他们找对地方了。

如果你在像哈萨克斯坦这样的审查国家,那么第一次通过 vpn 运行ning meteor 会有所帮助,因为它无法下载 gyp 插件。某处应该有一行关于下载失败,而不是当你 运行 meteor 启动时。