skip to Main Content

I have this error on angular docker project:

industrialareas_angular_ctnr | This version of CLI is only compatible with Angular versions ^13.0.0-next || >=13.0.0 <14.0.0,
industrialareas_angular_ctnr | but Angular version 12.2.16 was found instead.

My Dockerfile-angular file is:

FROM node:14
WORKDIR /usr/src/app
RUN npm uninstall -g @angular/cli
RUN npm uninstall @angular/cli
RUN npm i @angular/[email protected]
RUN npm cache clean --force
COPY ./project/package*.json .
RUN npm install
RUN npm link @angular/cli
COPY ./project .
EXPOSE 4200
CMD npm start

My docker-compose.yml file is:

version: '3.7'
services:
  angular:
    container_name: industrialareas_angular_ctnr
    build:
      context: .
      dockerfile: Dockerfile-angular
    restart: unless-stopped
    volumes:
      - ./project/src:/usr/src/app/src
    ports:
      - 4200:4200

And the package.json file is:

...
"dependencies": {
  ...
  "@angular/core": "~12.2.0",
  ...
},
"devDependencies": {
  ...
  "@angular/cli": "~12.2.8",
  ...

I have checked compatibility versions on this link

Anybody could help me please ? Thanks in advance.

2

Answers


  1. Chosen as BEST ANSWER

    The problem was that node brings the latest predefined version of angular cli, specifically @angular/[email protected] and the docker command took that by default.

    Replace this line on Dockerfile:

    RUN npm link @angular/cli
    

    to this:

    RUN npm link @angular/[email protected]
    

    and all works ok !


  2. Angular CLI version that u declared in JSON isn’t compatible with Angular core version u used: would be more clear if u post whole package.json file content.

    To solve issue, you can either upgrade angular core version to 13.0.0 and next, or you can downgrade angular cli version: the link doesn’t come from official documentation, so it’s not viable

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search