title: Error on deploying Next.js on AWS Amplify
body: <p>I was hosting my Next.js web app with SSR on AWS Amplify, until one day I was getting error 503.</p>
  <p><a href="https://i.stack.imgur.com/59vk5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/59vk5.png" alt="The error I got one day out of the blue" /></a></p>
  <p>Digging in the AWS console, I came across a CloudWatch log for the lambda function that handles the SSR part of the app.</p>
  <pre><code>2021-12-02T19:40:49.972Z    1bb29425-4acf-44aa-aabb-ba5afa558512    ERROR   Invoke Error    {
  &quot;errorType&quot;: &quot;Error&quot;,
  &quot;errorMessage&quot;: &quot;Cannot find module '@grpc/grpc-js/package.json'\nRequire stack:\n- /codebuild/output/src947501987/src/focalpick-client/node_modules/@firebase/firestore/dist/index.node.mjs&quot;,
  &quot;code&quot;: &quot;MODULE_NOT_FOUND&quot;,
  &quot;requireStack&quot;: [
      &quot;/codebuild/output/src947501987/src/focalpick-client/node_modules/@firebase/firestore/dist/index.node.mjs&quot;
  ],
  &quot;stack&quot;: [
      &quot;Error: Cannot find module '@grpc/grpc-js/package.json'&quot;,
      &quot;Require stack:&quot;,
      &quot;- /codebuild/output/src947501987/src/focalpick-client/node_modules/@firebase/firestore/dist/index.node.mjs&quot;,
      &quot;    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)&quot;,
      &quot;    at Function.Module._load (internal/modules/cjs/loader.js:746:27)&quot;,
      &quot;    at Module.require (internal/modules/cjs/loader.js:974:19)&quot;,
      &quot;    at require (internal/modules/cjs/helpers.js:93:18)&quot;,
      &quot;    at Object.578847 (/var/task/chunks/559.js:500372:34)&quot;,
      &quot;    at __webpack_require__ (/var/task/webpack-runtime.js:25:43)&quot;,
      &quot;    at Object.526541 (/var/task/chunks/962.js:2299:22)&quot;,
      &quot;    at __webpack_require__ (/var/task/webpack-runtime.js:25:43)&quot;,
      &quot;    at Module.778514 (/var/task/chunks/962.js:2021:20)&quot;,
      &quot;    at __webpack_require__ (/var/task/webpack-runtime.js:25:43)&quot;
  ]}
  </code></pre>
  <p>The error says that it cannot find module <code>@grpc/grpc-js</code>. It seems that this is a package that Firebase uses internally. I tried installing the package in my repository, re-deployed the Amplify app, but this wouldn't help. Trying to deploy a clean next app worked though.</p>
  <p>All the issues and questions I've read didn't help me find a solution.</p>