错误:在docker集装箱中找不到模块“纤维/未来”

一个Meteor项目在本地机器上运行OK,它用于在EC2泊坞窗容器上正常工作,但由于某种原因,现在它失败了,这里是我从EC2中发现的:

docker logs be664c9bce8a /opt/bundle/programs/server/boot.js:392 }).run(); ^ Error: Cannot find module "fibers/future" at Object.require (/opt/bundle/programs/server/boot.js:232:24) at packages/meteor.js:93:20 at packages/meteor.js:263:4 at packages/meteor.js:1392:3 at /opt/bundle/programs/server/boot.js:339:34 at Function._.each._.forEach (/opt/bundle/node_modules/underscore/underscore.js:153:9) at /opt/bundle/programs/server/boot.js:158:5 at /opt/bundle/programs/server/boot.js:388:5 at Function.run (/opt/bundle/programs/server/profile.js:510:12) at /opt/bundle/programs/server/boot.js:387:11 

这里是docker文件:

 FROM lambdalinux/baseimage-amzn #RUN yum update -y RUN curl --silent --location https://rpm.nodesource.com/setup_4.x | bash - RUN yum install -y tar nodejs gcc-c++ make ADD ./novice-driver.tar.gz /opt/ EXPOSE 8000 ENV ROOT_URL https://novicedriver.com.au ENV MONGO_URL "mongodb://abc:xyz@cluster0...sDB?ssl=true&replicaSet=Cluster0-shard-0&authSource=myDB" ENV PORT 8000 WORKDIR /opt/bundle/ RUN npm install fibers underscore source-map-support semver CMD node ./main.js 

任何build议如何解决这个问题? 谢谢

在Docker容器中,你应该先为你的包安装npm模块:

 # Install node modules WORKDIR /opt/bundle/programs/server RUN npm install WORKDIR /opt/bundle # do you other stuff 

而且,在构build应用程序包(在本地机器或CI服务器上)之前,最好使用: meteor npm install --production而不仅仅是npm install --production