【发布时间】:2021-05-17 14:50:10
【问题描述】:
当我尝试构建 Docker 文件时,出现以下错误
无法读取未定义的属性“0”时出现错误
npm 错误!代码生命周期
npm 错误!错误号 1 npm
错误! ssf@0.0.0 build:ssr:
ng build --prod && ng run ssf:server:productionnpm ERR!退出状态 1
请在下面找到我的 Docker 文件
FROM node:10.16.3-slim AS build
WORKDIR /app
COPY ./package.json ./package-lock.json /app/
RUN npm install
COPY . /app
ENV NODE_OPTIONS --max-old-space-size=4096
RUN npm run build:ssr **(Error is coming at this line)**
COPY --from=build /app/package.json /app
COPY --from=build /app/dist /app/dist
EXPOSE 4000
ENV NODE_ENV production
CMD ["npm", "run", "serve:ssr"]
另外,这是 package.json 快照
{
"name": "ssf",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"dev:ssr": "ng run ssf:serve-ssr",
"serve:ssr": "node dist/server/main.js",
"build:ssr": "ng build --prod && ng run ssf:server:production",
"prerender": "ng run ssf:prerender"
},
【问题讨论】: