我正试图通过码头从我的lerna monorepo中部署一个单角度客户端。
为此,我创建了以下Docker文件。
# Build environment
FROM node:12.2.0-alpine as build
# Work dir
WORKDIR /usr/src/app
# Set env values
ENV LOG_LEVEL=debug
ENV NODE_ENV=production
# Add lerna
COPY package.json .
COPY lerna.json .
RUN npm i lerna @angular/cli -g --loglevel notice
# Copy packages
COPY packages/client ./packages/client
# bootstrap
RUN yarn install --production --no-optional
RUN lerna bootstrap --scope=@proj/client -- --production --no-optional
# build
RUN lerna run build:prod --scope=@proj/client
# Run environment
FROM nginx:1.16.0-alpine
COPY --from=build ./packages/client/dist/client /usr/share/nginx/html
COPY --from=build ./packages/client/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]但是,当运行docker build -t test -f packages/client/Dockerfile .时,它会给出以下错误:
lerna notice cli v3.22.1
lerna notice filter including "@proj/client"
lerna info filter [ '@proj/client' ]
lerna info Executing command in 1 package: "yarn run build:prod"
lerna ERR! yarn run build:prod exited 127 in '@proj/client'
lerna ERR! yarn run build:prod stdout:
yarn run v1.15.2
$ ng build --prod
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run build:prod stderr:
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /usr/local/lib/node_modules/@angular/cli/models/architect-command.js
- /usr/local/lib/node_modules/@angular/cli/commands/build-impl.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /usr/local/lib/node_modules/@angular/cli/utilities/json-schema.js
- /usr/local/lib/node_modules/@angular/cli/models/command-runner.js
- /usr/local/lib/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng
See "/tmp/ng-OFgChe/angular-errors.log" for further details.
error Command failed with exit code 127.我尝试了几个#引导块的组合:
yarn install--production和--no-optional标志devDependencies移动到根package.json在本地运行这些命令(在清理的工作文件夹上)运行得很好,但每个命令在我的停靠程序构建中都给出了相同的结果。所以并不是说@angular-devkit没有被列为可靠的
有人知道怎么解决这个问题吗?
发布于 2020-10-27 19:25:48
找到了解决问题的方法。显然,不管有没有--production,纱线都不重要
将其更改为--production=false或将NODE_ENV更改为其他东西可以解决此问题
https://stackoverflow.com/questions/64561285
复制相似问题