Failed to compile error during creating PWA with next.js

Viewed 785

I run the command : npm run build

Error : info - Creating an optimized production build
Failed to compile.

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

Build failed because of webpack errors

1 Answers

If your version of next-pwa is 5.6 and your next.config.js is like this:

const withPWA = require('next-pwa')
const runtimeCaching = require('next-pwa/cache')  

module.exports = withPWA({
  pwa: {
    dest: 'public',
    runtimeCaching,
  },
})

Then you should consider changing it as written in the README.md file:

const withPWA = require('next-pwa')({
  dest: 'public'
})

module.exports = withPWA({
  // next.js config
})

I encountered this issue when I followed the pwa example of nextjs. My next-pwa version is 5.6 and the example's version is 5.5.4, so it dosen't work.

Related