Encountering a compilation issue while building a Next.js application with next-pwa integration

I've encountered an issue while trying to run my local Next.js project (v 12.2.2). The dev script isn't behaving as expected even after installing all necessary dependencies. I'm struggling to identify the root cause of this problem.

Upon running the script, the terminal displays the following message:

https://i.sstatic.net/I7tFo.png

error - Please check your GenerateSW plugin configuration: [WebpackGenerateSW] 'reactStrictMode' property is not expected to be here. Did you mean property 'exclude'?

Here's the content of the next.config.js file:

const withPWA = require("next-pwa");

module.exports = withPWA({
    reactStrictMode: true,
    webpack5: true,
    webpack: (config) => {
        config.resolve.fallback = { fs: false };
        return config;
    },
    pwa: {
        dest: "public",
        register: true,
        disable: process.env.NODE_ENV === "development",
    },
    images: {
        domains: ["pbs.twimg.com", "img.icons8.com", "gateway.moralisipfs.com", "ipfs.moralis.io", "lh3.googleusercontent.com", "www.artnews.com"],
    },
    // for running with docker
    output: "standalone",
});

And here's the package.json file snippet:

{
  "name": "musixverse-client",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "postbuild": "next-sitemap"
  },
  "dependencies": {
    "@headlessui/react": "^1.6.6",
    "@heroicons/react": "^1.0.5",
    "@walletconnect/web3-provider": "^1.7.8",
    "@web3auth/web3auth": "^1.1.1",
    ...
  },
  "node-version": "16.17.0",
  "npm-version": "8.19.0"
}

Answer №1

Your implementation of the next-pwa plugin needs adjustment for version 5.6.0. There was a significant change made that altered the plugin signature (refer to next-pwa/releases/tag/5.6.0).

Starting from version 5.6.0, the function signature of this plugin has been updated to align with best practices recommended by next.js. Primarily, it involves separating the pwa config from other next.js configurations.

As per the documentation for version 5.6.0, your configuration should resemble the following structure.

// Configure `next-pwa` settings here
const withPWA = require("next-pwa")({
    dest: "public",
    register: true,
    disable: process.env.NODE_ENV === "development",
});

// Utilize `withPWA` along with general Next.js configs
module.exports = withPWA({    
    reactStrictMode: true,
    webpack5: true,
    webpack: (config) => {
        config.resolve.fallback = { fs: false };
        return config;
    },
    images: {
        domains: ["pbs.twimg.com", "img.icons8.com", "gateway.moralisipfs.com", "ipfs.moralis.io", "lh3.googleusercontent.com", "www.artnews.com"]
    },
    output: "standalone"
});

Answer №2

I'm having trouble with my current setup and receiving the following error:

Uncaught (in promise) bad-precaching-response: There is an issue with the precaching response: [{"url":"https://mydomain.or/_next/static/TtNoj27ce4xV1zZzFfm_C/_buildManifest.js","status":404}]

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

Tips for changing the content of a text input field using JavaScript/jQuery

I am looking to dynamically change the values of specific form elements, particularly input text fields. However, when I load my HTML page, the input field appears blank instead of containing the value 1. Below is an example of my current approach. <!D ...

JWT authentication for restricted routes

I'm currently developing an application that requires users to log in and allows them to join private groups. I have successfully implemented the login part using JWT, but I'm struggling with how to prevent users from joining private groups until ...

YouTube: Embed two videos on a single webpage

I have a JavaScript question regarding the YouTube API. I made some modifications to the YouTube iFrame API in order to display two videos simultaneously, with one playing automatically and the other not. However, I am facing an issue where only the second ...

Counting specific data in Angular 2 component using .length property in html or ts file

Here is a script example: //dummy data source for list import { healthModel } from './healthModel'; export const healthListAll: healthModel[] = [ { id: 1, Name: 'Asparagus', healthGroup: 'Vegetable', ...

Having trouble embedding Hangouts button in HTML template using script tags

When I include a Hangouts button on my index page, it is visible and functional as expected: <body ng-app="sampleApp" ng-controller="MainCtrl"> <div class="row"> <div class="col-md-12 m-body"> <div class="m ...

Currently, I am expanding my knowledge of PHP and MySQL by working on a dynamic form that utilizes arrays. As I progress through the project,

One of my recent projects involved creating dynamic rows in a form using code. I managed to save the data in an array and display it using a foreach loop, but I'm facing challenges when trying to insert this data into a database. Here's a glimps ...

Getting numerous MongoDB records with identical attributes by means of Express

I am attempting to retrieve all MongoDB entries associated with a specific username using Express. Here is the code I have written: transcriptRepository.getTranscriptByUsername = (username) => { return Transcript.find({ username }) .then( tran ...

Blending Zend Framework with the Power of JavaScript Libraries

I've been diving into the world of Zend Framework for a few months now and have had success implementing view helpers, action helpers, and partials. Recently, I've discovered some interesting JavaScript libraries like TinyMCE that I'd like t ...

calculating the rotation angle from the origin to a vector within a three-dimensional space using three.js

I am working with a vector in three-dimensional space. Is there a method to determine the angle of rotation from the origin to this vector on each axis? For example, if the vector is located at x=6, y=-10, z=20, what angle does the vector make with resp ...

Retrieving the precise td data for computation

I'm working on a piece of code where I need to extract specific values from table cells when an input is made. I've written some code, but it's not returning the desired value. Can someone help me identify and correct my mistake? I can succe ...

Tips for incorporating user-entered data from a text box into a JavaScript function and utilizing a loop

Although my code is functioning correctly, I am looking to make some adjustments but seem to be struggling to achieve the desired outcome. Essentially, I have two labels and an input field in which the user is prompted to enter a specific number of weeks ...

Utilizing Observables in NestJS: Exploring SSE and EventEmitter

I am working on a project where I need to display an event that occurs in the backend on the frontend. Since it is a one-way communication, I have decided to use SSE (Server Sent Events) in nestjs to push the event to the frontend. The setup, as per the do ...

Navigating through various JSON arrays using Angular

I am currently working with a large JSON file in Angular and trying to iterate through it. The structure of the JSON file is as follows: { "subject1":[ { "title":"titlehere", "info":"infohere." }], ...

Tips for sending properties to a Material-UI styled component

I am facing a challenge with passing props to a component that already has internal props for handling styling. I am not sure how to manage both sets of props effectively. Below is my current setup. const styles = theme => ({ // Theme building }); ...

Tips for Editing and Modifying Name and Area in a Database

I'm currently working with React to develop a full CRUD application, but I'm facing challenges in updating the names and areas of rooms within houses. Any suggestions or insights on how to achieve this would be greatly appreciated. Apologies for ...

The data in Next.js getStaticProps does not update or refresh as expected

As I recently transitioned to working with Next.js, I have encountered several challenges. One issue that arose was related to the use of useEffect in React compared to its behavior in Next.js. In my index file, I have implemented the following code: impo ...

What is causing the table to not be displayed in this Javascript program when it is used in a

I am currently experimenting with incorporating an infinite loop before the prodNum and quantity prompts to consistently accept user input and display the output in a table. Although the program is functional when executed, it fails to showcase the table ...

The specified type does not meet the constraint as it lacks the required index signature

I'm currently working on refactoring a TypeScript project that utilizes React Hooks. While I have some knowledge of TypeScript, I am still more of a beginner than an expert. My main goal is to create reusable code for this project through the use of ...

Retrieve the value of an array in reactjs based on a specific condition

Here's an array I have: array = [ { period: 1, currency: 1, cost: 100, count: 10 }, { period: 1, currency: 2, cost: 200, count: 10 }, { period: 2, currency: 1, cost: 300, count: 20 }, { period: 3, currency: 3, cost: 400, count: 30 } ] I' ...

Access the value within an object that contains an array and compare it with a different array

array1 = [{id: 1, email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92e6f7e1e6a3d2e6f7e1e6bcf1fdff">[email protected]</a>', group_ids: ["25"], username: 'test1'}, {id: ...