NPM -如果与docker一起运行,则找不到模块



我正在尝试用docker运行我的vue应用程序。在本地更新npm包后,我得到以下错误:

-  Building for production...
ERROR  Failed to compile with 1 error8:17:57 AM
This relative module was not found:
* ../internals/a-function in ./node_modules/core-js/internals/new-promise-capability.js
ERROR  Build failed with errors.

在Windows下,一切正常。我已经尝试添加最新的core-js模块并恢复包。Json到一个稳定的状态,但没有成功。我不知道我错过了什么。

我Dockerfile:

# develop stage
FROM node:lts-alpine as develop-stage
WORKDIR /app
COPY app/package*.json ./
RUN npm install
COPY app/. .
# build stage
FROM develop-stage as build-stage
RUN npm run build
# production stage
FROM nginx:alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 90
CMD ["nginx", "-g", "daemon off;"]

我package.json:

{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/vue-fontawesome": "^2.0.6",
"@growthbunker/vuedarkmode": "^0.5.56",
"axios": "^0.21.4",
"colormap": "^2.3.2",
"core-js": "^3.18.2",
"json-loader": "^0.5.7",
"numeral": "^2.0.6",
"prismjs": "^1.25.0",
"pvw-visualizer": "^3.2.2",
"splitpanes": "^2.3.8",
"vue": "^2.6.11",
"vue-json-editor": "^1.4.3",
"vue-json-pretty": "^1.8.1",
"vue-numeral-filter": "^2.0.0",
"vue-numerals": "^4.0.6",
"vue-plotly": "^1.1.0",
"vue-prism-editor": "^1.3.0",
"vue-remote-component": "^1.4.0",
"vue-vtk-js": "^1.1.6",
"vuescroll": "^4.17.3",
"vuetify": "^2.5.10",
"yaml-loader": "^0.6.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.5.14",
"@vue/cli-plugin-eslint": "^4.5.14",
"@vue/cli-service": "^4.5.14",
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-vue": "^7.19.1",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"vue-cli-plugin-vuetify": "^2.4.3",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.7.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

删除构建阶段,以某种方式修复它:

# develop stage
FROM node:lts-alpine as develop-stage
WORKDIR /app
COPY app/package*.json ./
RUN npm install
COPY app/. .
# # build stage
# FROM develop-stage as build-stage
RUN npm run build
# production stage
FROM nginx:alpine as production-stage
COPY --from=develop-stage /app/dist /usr/share/nginx/html
EXPOSE 90
CMD ["nginx", "-g", "daemon off;"]