Kay
Kay

Reputation: 19680

Angular 6 Docker Build - ERROR in The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.8.3 was found instead

I am creating a docker image for my angular project.

In the package.json it referrs to "typescript": "^2.7.2"

I run docker build -t demo:production . and get the following error:

ERROR in The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.8.3 was found instead.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `ng build "--configuration" "production"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-05-23T11_16_37_049Z-debug.log

package.json

{
  "name": "demo",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.0",
    "@angular/cdk": "^6.0.0",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/flex-layout": "^6.0.0-beta.15",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/material": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "@auth0/angular-jwt": "^2.0.0",
    "@types/chartjs": "0.0.31",
    "@types/googlemaps": "^3.30.8",
    "@types/lodash": "^4.14.108",
    "auth0-js": "^9.5.1",
    "auth0-lock": "^11.6.1",
    "chart.js": "^2.7.2",
    "chartjs-plugin-annotation": "^0.5.7",
    "chartjs-plugin-datalabels": "^0.3.0",
    "core-js": "^2.5.5",
    "d3": "^5.1.0",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "json-formatter-js": "^2.2.0",
    "lodash": "^4.17.10",
    "lodash-es": "^4.17.10",
    "moment": "^2.22.1",
    "npm": "^6.0.0",
    "progressbar.js": "^1.0.1",
    "rxjs": "^6.1.0",
    "rxjs-compat": "^6.1.0",
    "ua-parser-js": "^0.7.18",
    "wordcloud": "^1.1.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.0",
    "@angular/cli": "^6.0.0",
    "@angular/compiler-cli": "^6.0.0",
    "@angular/language-service": "^6.0.0",
    "@types/d3": "^5.0.0",
    "@types/jasmine": "~2.8.7",
    "@types/jasminewd2": "~2.0.3",
    "@types/lodash-es": "^4.17.0",
    "@types/node": "^10.0.4",
    "codelyzer": "^4.3.0",
    "eslint": "^4.19.1",
    "jasmine-core": "~3.1.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.2",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.4.2",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^1.0.0",
    "protractor": "~5.3.1",
    "source-map-explorer": "^1.5.0",
    "ts-node": "~6.0.3",
    "tslint": "~5.10.0",
    "typescript": "^2.7.2"
  }
}

DockerFile

# Stage 0 - Pre-requisite: Based On Node.js to build and compile Demo Angular App.

FROM node:8.11.2 as node

WORKDIR /app

COPY package.json /app/

RUN npm install

COPY ./ /app/

ARG env=production

RUN npm run build -- --configuration $env

# Stage 1 - Based On Nginx to have a compiled and production ready build.

FROM nginx:1.14

COPY --from=node /app/dist/ /usr/share/nginx/html

COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf

Upvotes: 0

Views: 2029

Answers (1)

Sangwin Gawande
Sangwin Gawande

Reputation: 8166

Angular 6 Needs TypeScript version between 2.7.2 and 2.8.0.

That is why its throwing error.

Run following command to fix :

npm install [email protected]

OR

You can change it in package.json like following and run npm install again.

Typescript Version

Upvotes: 2

Related Questions