The development mode of NextJS is experiencing issues, however, the build and start commands are functioning normally

Just finished creating a brand new Next app (version: 12.0.7) using Typescript and Storybook. Everything seems to be working fine - I can successfully build and start the server. However, when I try to run dev mode and make a request, I encounter the following error in the browser:

Error in Browser:

Uncaught ReferenceError: __webpack_require__ is not defined

No error messages in the backend.

The libraries I'm using include Chakra UI, next-i18next, and next-auth.

To Reproduce the Error:

  1. Start by creating a new Next app with typescript using this command: npx create-next-app@latest --ts
  2. Once you've created the app, you may encounter an error stating exports is not defined. To work around this issue, you can follow the solution provided in this StackOverflow thread. Create a custom _document.tsx file with the code snippet below:
import Document, {
    Html,
    Head,
    Main,
    NextScript,
    DocumentContext,
} from "next/document"

class MyDocument extends Document {
    static async getInitialProps(ctx: DocumentContext) {
        const initialProps = await Document.getInitialProps(ctx)
        return {...initialProps}
    }

    render() {
        return (
            <Html>
                <Head />
                <body>
                <Main />
                <script>var exports = {"{}"};</script>
                <NextScript />
                </body>
            </Html>
        )
    }
}

export default MyDocument
  1. Run yarn run dev
  2. Visit http://localhost:3000/
  3. Check the console for any errors

Answer №1

IDENTIFIED THE CULPRIT!

Upon loading the website in Chrome (a browser I rarely use that has no extensions), everything ran smoothly. It wasn't until further investigation that I discovered my Anti-Ad-Blocker was causing the issue. Disabling it ultimately fixed the error!

Answer №2

I encountered a similar problem where the next dev command displayed:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /.../.env
event - compiled client and server successfully in 6.4s (2106 modules)

However, when I tried to access the site using Chrome or another browser, it would just keep loading indefinitely without any progress.

Upon investigation, I discovered that the issue was caused by the VPN service I had enabled (CyberGhost). Once I disabled the VPN, the website functioned correctly again.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Bootstrap not being recognized in AngularJS HTML

I've been working on learning AngularJS, but unfortunately I can't seem to get any Bootstrap themes to show up in my web application. Here is the HTML code for the header that I've been trying: <nav class="navbar navbar-default"> ...

I plan to compile a collection of names in a text field and then have the ability to select and access each name individually with just a click

I am currently working on a project that involves creating an admin site using Firebase. One of the main features of the site is large text fields that display information which can be modified. For instance, the user management page includes text fields ...

Refresh a div with Ajax once all data has been fully loaded

I am currently using an ajax refresh div function that reloads a specific div every 10 seconds. Occasionally, the div loads before receiving data from mysql. Is there a way to modify it so that it waits 2 seconds after reloading the div? <script type ...

Querying multiple collections in MongoDB using aggregate and populate functions to search across multiple fields

Within our database, we have two collections: Ad and Company. It is possible for a company to have multiple ads associated with it. We are in need of an API endpoint that can retrieve ads based on a keyword search. This search should span across the compa ...

AngularJS File Input element triggering only once when selecting the same file

I have created an Angular directive to customize the file upload input. directive('ngFile', function () { return { link: function (scope, element, attrs) { var button = element.find('button[data-fileInputButton]&apos ...

Tips for keeping your Timezone in check

My situation involves a client in India and a server in the USA. When a user submits a post from India, it gets stored on the USA server, causing the post submission time to be displayed in USA time. I am looking for a solution to display the post submit ...

The PhoneInputWithCountry component does not accept value changes through events

My current project involves utilizing the PhoneInputWithCountry component from react-phone-number-input within Next.js 14. I am facing an issue where I need to automatically set a value in the PhoneInputWithCountry component when the user interacts with a ...

What strategies can I employ to speed up the slow build times in next.js?

Having thoroughly explored the Next JS documentation and delved into related inquiries like Slow page build time in development with Next.js and TypeScript (although that pertains to TypeScript specifically - this concern revolves around JavaScript without ...

Using JavaScript to apply styling on images with overlays

I am currently facing an issue with placing an overlay on top of a background image. Despite my efforts, I am unable to get the background color to appear on top of the image. Any helpful suggestions on how to resolve this would be greatly appreciated. M ...

Learn how to gradually make text disappear and reappear using JavaScript or jQuery

I am a beginner in JavaScript and jQuery, and I am trying to achieve a text fade-out effect. Once the text has completely faded out, I want it to return with the same fade-in effect. I have been exploring if statements and fadeIn effects, but I am strugg ...

Filtering Tables with AngularJS

Currently, I'm experimenting with using angularJS to filter data in a table. My goal is to load the data from a JSON file that has a structure like this (example file): [{name: "Moroni", age: 50}, {name: "Tiancum", age: 43}, { ...

VS-Code is not a fan of accessors when targeting ES6

I can't seem to figure out this strange issue I'm having with VS-Code (1.13.1, MacOS). Every time I try to use a class getter or setter, I get the following error: [ts] Accessors are only available when targeting ECMAScript 5 and higher. The ...

Using JavaScript to retrieve and compare element values for a total sum

Given two arrays, the goal is to determine if any two numbers in the array add up to 9. The function should return either true or false. For example: array1 [1, 2, 4, 9] has no pair that sums up to 9, so it returns false array2 [1, 2, 4, 5] does have a ...

What are the specific actions performed on the server and on the client in ReactJS when rendering a component?

I've recently delved into the world of ReactJS, following tutorials and reading the documentation, but I'm still struggling to grasp a fundamental concept about how React actually operates. When a page is served, what exactly occurs behind the s ...

Learn how to generate a DataTable in C# by parsing multiple nested JSON Objects efficiently

Whenever I receive dynamic JSON data, it could be a JSON array, a simple JSON object, or nested JSON objects. I am attempting to deserialize and convert the JSON object/array into a DataTable for further processing using Newtonsoft.Json. Here is my curre ...

Steps to altering the color of a second button with a button click

My goal is to create a button click function that allows only one button to be clicked at a time. For instance, when btn1 is clicked, its background color changes from transparent to green. Then, if btn2 is clicked, btn1's background color should chan ...

Tips for creating a clickable A href link in the menu bar that triggers an accordion to open in the body when clicked - html

Is there a way to open the first accordion when clicking on the "open 1st accordion" link, and do the same for the second link? The accordions themselves work perfectly fine, I just need a way to trigger them from outside their scope by clicking on links i ...

Modifying the background image of the <body> element in CSS to reflect the season based on the current month in the calendar

I'm struggling to change my HTML background based on the date. The code I've tried isn't working as expected and I can't seem to find any relevant examples to guide me. My goal is simple - I want the background of my HTML page to be ch ...

Conceal the <p> element when the user interacts with the internal href

After creating this document using JQuery, whenever the user clicks on different internal links, a div with id = "change" is loaded which effectively "erases" the content. My challenge at the moment is that while images are successfully deleted, text rema ...

What is the best way to loop through strings in a request object?

I am currently working with Express and need to scan the POST requests to create an array called openingTimes. After that, I want to generate a MongoDB document based on the user inputs. The code snippet below is functional, but I am looking for a way to ...