0

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
  • Could you provide here the result of ng --version command? Maybe @angular/cli is installed globally and its version is higher than 12.2.8. Commented Feb 9, 2022 at 16:31
  • Can you edit the question to include a more complete minimal reproducible example? You mention a Docker project and the error message looks like Docker Compose output; what's in your Dockerfile, and are you doing something like using a anonymous volume for your node_modules tree in the docker-compose.yml? Commented Feb 9, 2022 at 16:35

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
0

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 !

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.