0
Error: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at S (/vercel/path0/node_modules/react/cjs/react.production.min.js:18:327)
    at Object.exports.useState (/vercel/path0/node_modules/react/cjs/react.production.min.js:23:277)
    at SessionProvider (/vercel/path0/node_modules/next-auth/react/index.js:422:31)
    at Wc (/usr/local/share/.config/yarn/global/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/usr/local/share/.config/yarn/global/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/usr/local/share/.config/yarn/global/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)

/// app.js

import "../styles/globals.css";
import type { AppProps } from "next/app";
import Top from "@components/top";
import Footer from "@components/footer";
import { SessionProvider } from "next-auth/react";
import { SWRConfig } from "swr";
import { RecoilRoot } from "recoil";
import { Session } from "next-auth";

    function MyApp({
      Component,
      pageProps: { session, ...pageProps },
    }: AppProps<{
      session: Session;
    }>) {
      return (
        <SessionProvider session={session}>
          <SWRConfig
            value={{
              fetcher: (url: string) =>
                fetch(url).then((response) => response.json()),
            }}
          >
            <RecoilRoot>
              <div className=" min-w-[300px]  max-h-fit flex flex-col items-center min-h-[100vh] relative">
                <Top />
                <section className=" mt-10 mx-3 flex-column items-center pb-[60px]">
                  <Component {...pageProps} />
                </section>
                <Footer />
              </div>
            </RecoilRoot>
          </SWRConfig>
        </SessionProvider>
      );
    }
    
    export default MyApp;

On almost every page this error happens when deploying.

I reinstalled npm and checked if I used hook in wrong way but seems not.

Is there any solution for this??

I'd just want to know where the errors happened.

3
  • use development build locally it will provides helpful warnings about problems in your apps . then debug your app before deploying Commented Oct 4, 2022 at 12:02
  • 1
    @monim No error exist even on production mode on local. The problems only happen while deploying on vercel.... How could I get through with this problem? Commented Oct 6, 2022 at 16:19
  • you could Try to delete your node_modules and .next folder from your local project and then run npm run build again. Commented Oct 6, 2022 at 22:57

2 Answers 2

1

Try using yarn instead:

yarn run build

I have tried using next build & npm run build but only yarn works in my case!

Sign up to request clarification or add additional context in comments.

Comments

-1

In my case, i had to change swcMinify: true to swcMinify: false in next.config.js

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.