title: I get an error when I try to run yarn build in next.js
body: <p>I am trying to build my next.js project using the <code>yarn build</code> command but I always get this error:</p>
  <pre><code>Error: Export encountered errors on following paths:
          /settings
      at D:\web3\futnft\frontend\node_modules\next\dist\export\index.js:498:19
      at runMicrotasks (&lt;anonymous&gt;)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async Span.traceAsyncFn (D:\web3\futnft\frontend\node_modules\next\dist\trace\trace.js:75:20)
      at async D:\web3\futnft\frontend\node_modules\next\dist\build\index.js:1024:17
      at async Span.traceAsyncFn (D:\web3\futnft\frontend\node_modules\next\dist\trace\trace.js:75:20)
      at async D:\web3\futnft\frontend\node_modules\next\dist\build\index.js:898:13
      at async Span.traceAsyncFn (D:\web3\futnft\frontend\node_modules\next\dist\trace\trace.js:75:20)
      at async Object.build [as default] (D:\web3\futnft\frontend\node_modules\next\dist\build\index.js:82:25
  </code></pre>
  <p>This is my index.tsx file under <code>pages/settings</code>:</p>
  <pre class="lang-js prettyprint-override"><code>import { ethers } from &quot;ethers&quot;;
  import { NextPage } from &quot;next&quot;;
  import React from &quot;react&quot;;
  import { Settings as SettingsComponent } from &quot;../../components/Settings&quot;;
  
  interface Props {
    setLoader: (loader: boolean) =&gt; void;
    futNFTTraining: ethers.Contract;
    futNFTMatch: ethers.Contract;
  }
  
  const Settings: NextPage&lt;Props&gt; = ({
    setLoader,
    futNFTMatch,
    futNFTTraining,
  }) =&gt; {
    return (
      &lt;SettingsComponent
        setLoader={setLoader}
        futNFTMatch={futNFTMatch}
        futNFTTraining={futNFTTraining}
      /&gt;
    );
  };
  
  export default Settings;
  </code></pre>
  <p>This is the Settings.tsx file under <code>components/</code>:</p>
  <pre class="lang-js prettyprint-override"><code>import { ethers } from &quot;ethers&quot;;
  import Link from &quot;next/link&quot;;
  import React, { useState } from &quot;react&quot;;
  import settingsStyles from &quot;../styles/Settings.module.scss&quot;;
  
  interface Props {
    setLoader: (loader: boolean) =&gt; void;
    futNFTTraining: ethers.Contract;
    futNFTMatch: ethers.Contract;
  }
  
  export const Settings: React.FunctionComponent&lt;Props&gt; = ({
    futNFTMatch,
    futNFTTraining,
    setLoader,
  }) =&gt; {
    const setValue = async (setter: ethers.ContractFunction, value: any) =&gt; {
      setLoader(true);
      const tx = await setter(value);
      await tx.wait();
      setLoader(false);
    };
  
    const [formation, setFormation] = useState&lt;string&gt;(&quot;&quot;);
    const [positions, setPositions] = useState&lt;string[]&gt;([]);
    const [signer, _] = useState&lt;ethers.Signer&gt;(
      (window as any).provider.getSigner()
    );
    return (
      &lt;div className={settingsStyles.settingsContainer}&gt;
        &lt;h2&gt;Mint New NFTs&lt;/h2&gt;
        &lt;Link href=&quot;/mint&quot;&gt;
          &lt;a className={settingsStyles.link}&gt;Mint&lt;/a&gt;
        &lt;/Link&gt;
        &lt;h2&gt;Set State Variables&lt;/h2&gt;
        &lt;h3&gt;FutNFTTraining Smart Contract&lt;/h3&gt;
        &lt;div className={settingsStyles.item}&gt;
          &lt;span className={settingsStyles.variable}&gt;cooldown&lt;/span&gt;
          &lt;input
            type=&quot;number&quot;
            name=&quot;cooldown&quot;
            id=&quot;cooldown&quot;
            className={settingsStyles.value}
          /&gt;
          &lt;span className={settingsStyles.unit}&gt;seconds&lt;/span&gt;
          &lt;button
            className={settingsStyles.setBtn}
            onClick={async () =&gt; {
              await setValue(
                futNFTTraining.connect(signer).setCooldown,
                parseInt(
                  (document.getElementById(&quot;cooldown&quot;)! as HTMLInputElement).value
                )
              );
            }}
          &gt;
            Set
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div className={settingsStyles.item}&gt;
          &lt;span className={settingsStyles.variable}&gt;fee&lt;/span&gt;
          &lt;input
            type=&quot;number&quot;
            name=&quot;fee&quot;
            id=&quot;fee&quot;
            className={settingsStyles.value}
          /&gt;
          &lt;span className={settingsStyles.unit}&gt;MATIC&lt;/span&gt;
          &lt;button
            className={settingsStyles.setBtn}
            onClick={async () =&gt; {
              await setValue(
                futNFTTraining.connect(signer).setFee,
                parseInt(
                  (document.getElementById(&quot;fee&quot;)! as HTMLInputElement).value
                )
              );
            }}
          &gt;
            Set
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div className={settingsStyles.item}&gt;
          &lt;span className={settingsStyles.variable}&gt;maxLevel&lt;/span&gt;
          &lt;input
            type=&quot;number&quot;
            name=&quot;maxLevel&quot;
            id=&quot;maxLevel&quot;
            className={settingsStyles.value}
          /&gt;
          &lt;span className={settingsStyles.unit}&gt;&lt;/span&gt;
          &lt;button
            className={settingsStyles.setBtn}
            onClick={async () =&gt; {
              await setValue(
                futNFTTraining.connect(signer).setMaxLevel,
                parseInt(
                  (document.getElementById(&quot;maxLevel&quot;)! as HTMLInputElement).value
                )
              );
            }}
          &gt;
            Set
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;h3&gt;FutNFTMatch Smart Contract&lt;/h3&gt;
        &lt;div className={settingsStyles.item}&gt;
          &lt;span className={settingsStyles.variable}&gt;
            levelPercentSuitablePosition
          &lt;/span&gt;
          &lt;input
            type=&quot;number&quot;
            name=&quot;levelPercentSuitablePosition&quot;
            id=&quot;levelPercentSuitablePosition&quot;
            className={settingsStyles.value}
          /&gt;
          &lt;span className={settingsStyles.unit}&gt;%&lt;/span&gt;
          &lt;button
            className={settingsStyles.setBtn}
            onClick={async () =&gt; {
              await setValue(
                futNFTMatch.connect(signer).setLevelPercentSuitablePosition,
                parseInt(
                  (
                    document.getElementById(
                      &quot;levelPercentSuitablePosition&quot;
                    )! as HTMLInputElement
                  ).value
                )
              );
            }}
          &gt;
            Set
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div className={settingsStyles.item}&gt;
          &lt;span className={settingsStyles.variable}&gt;levelPercentNoPosition&lt;/span&gt;
          &lt;input
            type=&quot;number&quot;
            name=&quot;levelPercentNoPosition&quot;
            id=&quot;levelPercentNoPosition&quot;
            className={settingsStyles.value}
          /&gt;
          &lt;span className={settingsStyles.unit}&gt;%&lt;/span&gt;
          &lt;button
            className={settingsStyles.setBtn}
            onClick={async () =&gt; {
              await setValue(
                futNFTMatch.connect(signer).setLevelPercentNoPosition,
                parseInt(
                  (
                    document.getElementById(
                      &quot;levelPercentNoPosition&quot;
                    )! as HTMLInputElement
                  ).value
                )
              );
            }}
          &gt;
            Set
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div className={settingsStyles.item}&gt;
          &lt;span className={settingsStyles.variable}&gt;lineupFee&lt;/span&gt;
          &lt;input
            type=&quot;number&quot;
            name=&quot;lineupFee&quot;
            id=&quot;lineupFee&quot;
            className={settingsStyles.value}
          /&gt;
          &lt;span className={settingsStyles.unit}&gt;MATIC&lt;/span&gt;
          &lt;button
            className={settingsStyles.setBtn}
            onClick={async () =&gt; {
              await setValue(
                futNFTMatch.connect(signer).setLineupFee,
                parseInt(
                  (document.getElementById(&quot;lineupFee&quot;)! as HTMLInputElement)
                    .value
                )
              );
            }}
          &gt;
            Set
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div className={settingsStyles.item}&gt;
          &lt;span className={settingsStyles.variable}&gt;matchFee&lt;/span&gt;
          &lt;input
            type=&quot;number&quot;
            name=&quot;matchFee&quot;
            id=&quot;matchFee&quot;
            className={settingsStyles.value}
          /&gt;
          &lt;span className={settingsStyles.unit}&gt;MATIC&lt;/span&gt;
          &lt;button
            className={settingsStyles.setBtn}
            onClick={async () =&gt; {
              await setValue(
                futNFTMatch.connect(signer).setMatchFee,
                parseInt(
                  (document.getElementById(&quot;matchFee&quot;)! as HTMLInputElement).value
                )
              );
            }}
          &gt;
            Set
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div className={settingsStyles.formation}&gt;
          &lt;h4&gt;Add Formation&lt;/h4&gt;
          &lt;input
            type=&quot;text&quot;
            name=&quot;formationName&quot;
            id=&quot;formationName&quot;
            placeholder=&quot;Formation Name&quot;
            onChange={() =&gt; {
              const formationName = (
                document.getElementById(&quot;formationName&quot;)! as HTMLInputElement
              ).value;
              setFormation(formationName);
              if (formationName.length == 0) {
                setPositions([]);
              }
            }}
          /&gt;
          {formation.length &gt; 0 &amp;&amp; (
            &lt;&gt;
              &lt;div&gt;
                &lt;input
                  type=&quot;text&quot;
                  name=&quot;position&quot;
                  id=&quot;position&quot;
                  placeholder=&quot;Position&quot;
                /&gt;
                &lt;button
                  onClick={() =&gt; {
                    const position = (
                      document.getElementById(&quot;position&quot;)! as HTMLInputElement
                    ).value;
                    if (position.length &gt; 0 &amp;&amp; positions.length &lt; 11) {
                      const newArr = positions;
                      newArr.push(position);
                      setPositions(newArr);
                    }
                  }}
                &gt;
                  Add Position
                &lt;/button&gt;
              &lt;/div&gt;
              &lt;div className={settingsStyles.positions}&gt;
                {positions.map((position, key) =&gt; {
                  return (
                    &lt;div className={settingsStyles.position} key={key}&gt;
                      &lt;p&gt;{position}&lt;/p&gt;
                      &lt;button
                        onClick={() =&gt; {
                          const index = positions.indexOf(position);
                          const newArr = positions;
                          newArr.splice(index, 1);
                          setPositions(newArr);
                        }}
                      &gt;
                        ✗
                      &lt;/button&gt;
                    &lt;/div&gt;
                  );
                })}
              &lt;/div&gt;
              {positions.length == 11 &amp;&amp; &lt;button&gt;Add Formation&lt;/button&gt;}
            &lt;/&gt;
          )}
        &lt;/div&gt;
      &lt;/div&gt;
    );
  };
  
  export default Settings;
  </code></pre>
  <p>I found another Stack Overflow question with the same problem but wasn't able to solve my problem. I tried many things that removing useless props but didn't work.</p>