#build error

1 messages · Page 1 of 1 (latest)

rose belfry
#

I'm trying to build my project but i get the following error:

Export encountered errors on following paths:
/_error: /404
/_error: /500

rain magnetBOT
#

Hi @rose belfry. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

It looks like you're encountering a common issue during the build process where the export encounters errors on the paths /_error: /404 and /_error: /500. This issue has been reported in several instances and can be due to various reasons. Here are some steps and considerations to help you troubleshoot and resolve this issue:

Common Causes and Solutions

  1. Check for Null or Undefined Contexts:

  2. Custom Error Pages:

  3. Check Next.js Configuration:

    • Verify your next.config.js or next.config.ts for any experimental options or misconfigurations that might be causing the issue.
    • Example: An issue was reported when using experimental options in next.config.ts (Source: Issue 64866 (https://github.com/vercel/next.js/issues/64866)).
#
  1. Version Compatibility:
    • Ensure that you are using compatible versions of next, react, and react-dom. Sometimes upgrading or downgrading to a stable version can resolve the issue.
    • Example: Users reported issues when upgrading from Next.js 13.4.19 to 14.0.1 and found that downgrading resolved the issue (Source: Issue 57277 (https://github.com/vercel/next.js/issues/57277)).

Example Troubleshooting Steps

  1. Check for Null Contexts:

    // Ensure that all contexts are properly initialized
    const MyComponent = () => {
      const contextValue = useContext(MyContext);
      if (!contextValue) {
        // Handle the case where context is null or undefined
        return <div>Loading...</div>;
      }
      return <div>{contextValue.someProperty}</div>;
    };
    
  2. Review Custom Error Pages:

    // _error.js
    function Error({ statusCode }) {
      return (
        <p>
          {statusCode
            ? `An error ${statusCode} occurred on server`
            : 'An error occurred on client'}
        </p>
      );
    }
    
    Error.getInitialProps = ({ res, err }) => {
      const statusCode = res ? res.statusCode : err ? err.statusCode : 404;
      return { statusCode };
    };
    
    export default Error;
    
  3. Check Next.js Configuration:

    // next.config.js
    module.exports = {
      experimental: {
        // Ensure experimental options are correctly configured
      },
    };
    

If these steps do not resolve your issue, you may want to refer to the specific issues and discussions on GitHub for more detailed troubleshooting:


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@rose belfry kapa.ai is still learning and improving, please let us know how it did by reacting below