title: How can I build and deploy a app (NestJS) as azure web app?
body: <p>I am use the nx framework (<a href="https://nx.dev" rel="nofollow noreferrer">https://nx.dev</a>) to create an angular + Nest application. The angular app should be the frontend application and the nest app should be the REST-API. I have create a git repo in &quot;Azure DevOps&quot;.</p>
  <p>I create this applications with</p>
  <pre><code>npx create-nx-workspace@latest
  ? Workspace name (e.g., org name)     nxtest
  ? What to create in the new workspace angular-nest      [a workspace with a full stack application (Angular + Nest)]
  ? Application name                    test-app
  ? Default stylesheet format           CSS
  </code></pre>
  <p>After this, i have an Angular and a Nest application.</p>
  <p>I can start the angular frontend application with</p>
  <pre><code>nx serve test-app
  </code></pre>
  <p>and the Nest app (REST-API) with</p>
  <pre><code>ng serve api
  </code></pre>
  <p>It's worked an i can used the api at the browser.</p>
  <p>In the next step, i commit and push it to the git repo.</p>
  <p>I create in Microsoft Azure a Web-App.</p>
  <p><a href="https://i.stack.imgur.com/xqUO2.png" rel="nofollow noreferrer">Settings Microsoft Azure Web-App</a></p>
  <p>Now, i want to create a CI/CD step.</p>
  <p>In the azure portal ...</p>
  <ol>
  <li>Choose <strong>Deployment Center</strong></li>
  <li>Choose <strong>Azure Repos</strong></li>
  <li>Choose <strong>Azure Pipelines</strong></li>
  <li>Choose my Organization, Project, Repo, Branch and as Web Application Framework NodeJS and Task Runner &quot;None&quot;</li>
  </ol>
  <p><a href="https://i.stack.imgur.com/caMAu.png" rel="nofollow noreferrer">Settings for Deployment as Azure Web-App</a></p>
  <p>After this, i have a new build pipeline in my &quot;Azure DevOps&quot; Project.</p>
  <p>The create build pipeline run successful, but the build definition is somehow incomplete.</p>
  <ol>
  <li>Use Node version</li>
  <li>npm run install with the package.json</li>
  <li>Archive files</li>
  <li>Puplish build artifacts</li>
  </ol>
  <p>The result on Azure:</p>
  <ul>
  <li>All files are copied from git repo</li>
  <li>create a web.config wit iisnode as handler and the path is &quot;server.js&quot;</li>
  </ul>
  <p>But there are none start javascript file.</p>
  <p>So, i edit the build pipeline.</p>
  <p><a href="https://i.stack.imgur.com/n19Rl.png" rel="nofollow noreferrer">Use Node version 12.13.0</a></p>
  <p><a href="https://i.stack.imgur.com/jvgs8.png" rel="nofollow noreferrer">Install application dependencies</a></p>
  <p><a href="https://i.stack.imgur.com/lDNII.png" rel="nofollow noreferrer">Run Build</a>
  The script &quot;buildall&quot; -&gt; nx run-many --target=build --all --prod</p>
  <pre><code>Starting: build
  ==============================================================================
  Task         : npm
  Description  : Run an npm command. Use NpmAuthenticate@0 task for latest capabilities.
  Version      : 0.175.0
  Author       : Microsoft Corporation
  Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
  ==============================================================================
  C:\windows\system32\cmd.exe /D /S /C &quot;C:\hostedtoolcache\windows\node\12.13.0\x64\npm.cmd config list&quot;
  ; cli configs
  metrics-registry = &quot;https://registry.npmjs.org/&quot;
  scope = &quot;&quot;
  user-agent = &quot;npm/6.12.0 node/v12.13.0 win32 x64&quot;
  
  ; environment configs
  cache = &quot;C:\\npm\\cache&quot;
  prefix = &quot;C:\\npm\\prefix&quot;
  
  ; node bin location = C:\hostedtoolcache\windows\node\12.13.0\x64\node.exe
  ; cwd = D:\a\1\s\nxtest
  ; HOME = C:\Users\VssAdministrator
  ; &quot;npm config ls -l&quot; to show all defaults.
  
  C:\windows\system32\cmd.exe /D /S /C &quot;C:\hostedtoolcache\windows\node\12.13.0\x64\npm.cmd run buildall&quot;
  
  &gt; nxtest@0.0.0 buildall D:\a\1\s\nxtest
  &gt; nx run-many --target=build --all --prod
  
  
  &gt;  NX  Running target build for projects:
  
    - test-app
    - api
  
  ———————————————————————————————————————————————
  
  &gt; ng run api:build:production 
  Starting type checking service...
  Using 2 workers with 2048MB memory limit
  Hash: d814495e471a4bbc4f1b
  Built at: 10/06/2020 8:40:04 AM
  Entrypoint main = main.js main.js.map
  chunk    {0} main.js, main.js.map (main) 2.43 KiB [entry] [rendered]
  
  &gt; ng run test-app:build:production 
  
  chunk {} runtime.e227d1a0e31cbccbf8ec.js (runtime) 1.45 kB [entry] [rendered]
  chunk {1} main.47f3572e3dd98212c211.js (main) 122 kB [initial] [rendered]
  chunk {2} polyfills.9e86b32c42185429d576.js (polyfills) 36.1 kB [initial] [rendered]
  chunk {3} styles.280e991c5992f8630bc9.css (styles) 0 bytes [initial] [rendered]
  Date: 2020-10-06T08:40:42.853Z - Hash: 958a1c63d1211ca0510b - Time: 30858ms
  
  ———————————————————————————————————————————————
  
  &gt;  NX   SUCCESS  Running target &quot;build&quot; succeeded
  
  
  Finishing: build
  </code></pre>
  <p><a href="https://i.stack.imgur.com/TaOsM.png" rel="nofollow noreferrer">Archive files</a></p>
  <p><a href="https://i.stack.imgur.com/qKwZm.png" rel="nofollow noreferrer">Publish build artifacts</a></p>
  <p>When the run of the pipeline is finished, then i have this files in the wwwroot folder of the web app.</p>
  <ul>
  <li>main.js</li>
  <li>main.js.map</li>
  <li>web.config</li>
  </ul>
  <p>But if i run the app or visit the url, then i get allways the follow error in the console.</p>
  <pre><code>Application has thrown an uncaught exception and is terminated:
  Error: Cannot find module 'tslib'
  Require stack:
  - D:\home\site\wwwroot\main.js
  - D:\Program Files (x86)\iisnode\interceptor.js
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
      at Function.Module._load (internal/modules/cjs/loader.js:687:27)
      at Module.require (internal/modules/cjs/loader.js:849:19)
      at require (internal/modules/cjs/helpers.js:74:18)
      at Object.&lt;anonymous&gt; (D:\home\site\wwwroot\main.js:91:18)
      at __webpack_require__ (D:\home\site\wwwroot\main.js:20:30)
      at Module.&lt;anonymous&gt; (D:\home\site\wwwroot\main.js:225:63)
      at __webpack_require__ (D:\home\site\wwwroot\main.js:20:30)
      at Object.&lt;anonymous&gt; (D:\home\site\wwwroot\main.js:216:18)
      at __webpack_require__ (D:\home\site\wwwroot\main.js:20:30)
  Tue Oct 06 2020 08:16:28 GMT+0000 (Greenwich Mean Time): Application has thrown an uncaught exception and is terminated:
  Error: Cannot find module 'tslib'
  Require stack:
  - D:\home\site\wwwroot\main.js
  - D:\Program Files (x86)\iisnode\interceptor.js
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
      at Function.Module._load (internal/modules/cjs/loader.js:687:27)
      at Module.require (internal/modules/cjs/loader.js:849:19)
      at require (internal/modules/cjs/helpers.js:74:18)
      at Object.&lt;anonymous&gt; (D:\home\site\wwwroot\main.js:91:18)
      at __webpack_require__ (D:\home\site\wwwroot\main.js:20:30)
      at Module.&lt;anonymous&gt; (D:\home\site\wwwroot\main.js:225:63)
      at __webpack_require__ (D:\home\site\wwwroot\main.js:20:30)
      at Object.&lt;anonymous&gt; (D:\home\site\wwwroot\main.js:216:18)
      at __webpack_require__ (D:\home\site\wwwroot\main.js:20:30)
  </code></pre>
  <p>All my previous attempts to get the Nestjs application working have been in vain. I am grateful for any help.</p>