楼主这几天想用docker里运行一个vue应用,网上下载下来的是用yarn build进行发布的。但是每次Dockerfile执行到yarn build命令时都报同一个错误。internal/modules/cjs/loader.js:638
    throw err;
    ^Error: Cannot find module 'semver'
觉得很奇怪,并且在Dockerfile中install semver还是同样问题。查阅了网上资料,说这个模块应该时nodejs自带的。那么docker中的nodejs为什么没有这个模块呢。
贴上Dockerfile文件FROM node:10.16.3
# 如果你在国内,这行配置很有必要,不然打包会非常非常慢,原因嘛,都懂。
RUN npm config set registry https://registry.npm.taobao.org# install simple http server for serving static content
RUN npm install -g http-server# make the 'app' folder the current working directory
WORKDIR /app# copy both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./# install project dependencies
RUN yarn install# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .# build app for production with minification
RUN yarn buildEXPOSE 8080
# 加入端口自定义配置,避免与其他K8S容器端口冲突
CMD [ "http-server","-p","8080", "dist" ]