Angular在docker中不起作用,因为它找不到模块@ angular-devkit / build-angular

时间:2019-04-03 11:54:15

标签: angular asp.net-mvc-4 jasmine protractor cucumberjs

即使忽略了node_modules,我仍然面临相同的错误,我还是尝试忽略了node_modules,但仍然无法为我工作

yaml文件:

version: '3.5'

services:
    angular-docker:
        hostname: localhost
        container_name: angular-docker
        build: ./angular-doc
        volumes:
          - './angular-doc:/usr/src/app/'
        ports:
          - '4200:4200'

docker文件:

FROM node:10.12.0

RUN mkdir usr/src/app

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install -g @angular/cli@latest

COPY . .

EXPOSE 4200

CMD ng serve --host 0.0.0.0

1 个答案:

答案 0 :(得分:0)

您需要在您的angular项目中安装 @ angular-devkit / build-angular 软件包作为dev依赖项

npm install --save-dev @angular-devkit/build-angular

已更新!

您忘记在docker文件中添加RUN npm install

FROM node:10.12.0
RUN mkdir usr/src/app
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
RUN npm install -g @angular/cli@latest
COPY . .
EXPOSE 4200
CMD ng serve --host 0.0.0.0