title: npm run build error NG8001, NG8002, NG8003 during build docker image
body: <p>There are several errors during dockerizing my Angular project.</p>
  <p>The point is that there is no error when I run <code>ng serve</code> or <code>npm run build</code> command.
  I set <code>&quot;strict&quot;: false,</code> in tsconfig.json file as well.</p>
  <p>I used this command to the dockerize angular project:</p>
  <pre><code>docker build -t myProject:latest .
  </code></pre>
  <p><strong>Dockerfile:</strong></p>
  <pre><code>#stage 1
  FROM node:16.15.0 as node
  WORKDIR /app
  COPY . .
  RUN npm install
  RUN npm run build
  
  #stage 2
  FROM nginx:alpine
  COPY --from=node /app/dist/myProject /usr/share/nginx/html
  </code></pre>
  <p>I can say there is an error in every single component and module in my project, for example:</p>
  <pre><code>error NG8001: 'mat-paginator' is not a known element:
  error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors
  error NG8003: No directive found with exportAs 'ngForm'.
  error NG8002: Can't bind to 'pageSizeOptions' since it isn't a known property of 'mat-paginator'.
  error NG8002: Can't bind to 'length' since it isn't a known property of 'mat-paginator'.
  error NG8002: Can't bind to 'label' since it isn't a known property of 'app-text-input'.
  </code></pre>
  <p>Here is the latest output before the error comes up:</p>
  <p><a href="https://i.stack.imgur.com/IUzFA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IUzFA.png" alt="enter image description here" /></a></p>
  <p>All Versioning:</p>
  <pre><code>Angular CLI: 13.3.7
  Node: 16.15.0
  Package Manager: npm 8.5.5
  OS: win32 x64
  
  Angular: 13.3.10
  ... animations, common, compiler, compiler-cli, core, forms
  ... platform-browser, platform-browser-dynamic, router
  
  Package                         Version
  ---------------------------------------------------------
  @angular-devkit/architect       0.1303.7
  @angular-devkit/build-angular   13.3.7
  @angular-devkit/core            13.3.7
  @angular-devkit/schematics      13.3.7
  @angular/cdk                    12.2.13
  @angular/cli                    13.3.7
  @angular/material               12.2.13
  @schematics/angular             12.2.17
  rxjs                            6.6.7
  typescript                      4.6.4
  </code></pre>