Skip to content
TheChatArchiveThe Chat Archive
gpt-4-1106-preview· OpenAIAi2 WildChat-4.8M (AI2)

how to repair: npm run build build next build ▲ Next.js 14.1.0 ✓ Linting and checking…

  1. User

    how to repair: npm run build

    build next build

    ▲ Next.js 14.1.0

    ✓ Linting and checking validity of types
    Creating an optimized production build ... ✓ Compiled successfully ✓ Collecting page data
    Generating static pages (0/5) [= ]TypeError: Class constructor a cannot be invoked without 'new' at Wc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at $c (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at bd (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:217)

    Error occurred prerendering page "/lib/SceneInit". Read more: https://nextjs.org/docs/messages/prerender-error

    TypeError: Class constructor a cannot be invoked without 'new'
    at Wc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at c(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:78:98)atbd(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:77:404)atZ(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:7Generatingstaticpages(3/5)[===]TypeError:Classconstructoracannotbeinvokedwithout′new′atWc(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:68:44)atZc(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:70:253)atZ(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:76:89)atZc(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:70:481)atZ(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:76:89)atZc(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:70:481)atZ(C:\Users\VICE\Documents\three−js−games−main\09−snake\nodemodules\react−dom\cjs\react−dom−server.browser.production.min.js:76:89)atc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at bd (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:7 Generating static pages (3/5) [=== ] TypeError: Class constructor a cannot be invoked without 'new' at Wc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at c (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at bd (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:217)

    Error occurred prerendering page "/lib/SnakeGame". Read more: https://nextjs.org/docs/messages/prerender-error

    TypeError: Class constructor a cannot be invoked without 'new'
    at Wc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:44) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:253) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at Zc (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481) at Z (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89) at $c (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98) at bd (C:\Users\VICE\Documents\three-js-games-main\09-snake\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404) ✓ Generating static pages (5/5)

    Export encountered errors on following paths: /lib/SceneInit /lib/SnakeGame

  2. Assistant

    The error you're encountering is related to using ES6 classes with an environment or tools that do not fully support ES6 class syntax or require a different instantiation method.

    The error TypeError: Class constructor a cannot be invoked without 'new' often happens when you attempt to call a class as a function or if the class is transpiled in a way that prevents it from being called with new.

    Here are some steps to troubleshoot the issue:

    1. Check Babel Configuration: If you're using Babel, make sure your configuration supports ES6 classes correctly. For instance, @babel/preset-env should be configured properly, and you might need the @babel/plugin-transform-classes plugin if you're targeting older environments.

    2. Review Class Instantiation: Look at the code where a is defined and any other parts of your code where the a class is instantiated. Ensure that you're always using new to create instances of that class.

    3. Third-Party Libraries: Sometimes issues arise from third-party libraries that are not transpiled correctly for the target environment. Make sure the dependencies in your project are up-to-date and compiled to the correct JavaScript version.

    4. Next.js Version: Since you're using Next.js, make sure you're on a version that supports your codebase. Sometimes, updating (or in some cases, downgrading) to a compatible version can solve these issues.

    5. Transpile Node Modules: By default, Next.js does not transpile files inside node_modules. If the issue is being caused by a third-party library, you may need to customize your Next.js configuration to transpile that particular module. This is done using the next-transpile-modules package or custom Babel settings.

    6. Source Code Review: Review the components mentioned in the error message (/lib/SceneInit and /lib/SnakeGame). Ensure they are exporting classes correctly and are not unintentionally invoking classes without new.

    If you want to manually adjust your Babel configuration to ensure compatibility, you might add or adjust settings for preset-env and plugin-transform-classes in your .babelrc or babel.config.js file like so:

    {
      "presets": [
        ["@babel/preset-env", {
          "targets": {
            // specify targets here (e.g., browsers, Node.js versions)
          }
        }]
      ],
      "plugins": [
        ["@babel/plugin-transform-classes", {
          "loose": true // or false depending on your needs
        }]
      ]
    }
    

    Since this error is displayed during static generation, meaning SSR (Server-Side Rendering) specifically, ensure that any client-side code that is not compatible with SSR is either dynamically imported with the { ssr: false } option or guarded appropriately within component lifecycle methods meant for the browser environment (like componentDidMount in class components or useEffect with an empty dependency array in functional components).

    Finally, if you are unable to resolve the issue through configuration changes and version updates, you might need to refactor the code causing the issue to adopt a different pattern that does not rely on the problematic class construction.

    If these guidance steps don't resolve the issue, please provide additional code context or configurations for more targeted help.