2

I have created one webpack config for NextJS in next.config.js. I'm getting some build error after the compilation regarding the export path. Anyone please help me out to fix this issue. This is my next.config.js If any changes required help to avoid the error.

module.exports = {
    rewrites: async () => nextI18NextRewrites(localeSubpaths),
    publicRuntimeConfig: {
       localeSubpaths,
    },
    compress: true,
    webpack: (config, option) => {
        config.optimization = {
            splitChunks: {
            chunks: 'all',
            cacheGroups: {
                default: false,
                vendors: false,
                framework: {
                    name: 'framework',
                    chunks: 'all',
                    test: /[\\/]node_modules[\\/](react|react-dom|scheduler|prop-types)[\\/]/,
                    priority: 20,
                    minChunks: 5,
                    reuseExistingChunk: true,
               },
               lib: {
                   chunks: 'all',
                   test: (module) => {
                       return (
                           module.size() > 160000 && /node_modules[/\\]/.test(module.identifier()))
                    },
                    name: (module) => {
                        const rawRequest = module.rawRequest && module.rawRequest.replace(/^@(\w+)[/\\]/, '$1-') if (rawRequest) return rawRequest
                        const identifier = module.identifier()
                        const trimmedIdentifier = /(?:^|[/\\])node_modules[/\\](.*)/.exec(identifier)
                        const processedIdentifier = rimmedIdentifier && trimmedIdentifier[1].replace(/^@(\w+)[/\\]/, '$1-')    
                        return processedIdentifier || identifier
                    },
                    priority: 30,
                    minChunks: 2,
                    reuseExistingChunk: true,
              },
              commons: {
      name: 'commons',
      chunks: 'all',
      minChunks: 25,
      priority: 10,
      reuseExistingChunk: true,
    },
    shared: {
      name(module, chunks) {
        return require("crypto")
          .createHash('sha1')
          .update(
            chunks.reduce(
              (acc, chunk) => {
                return acc + chunk.name
              },
              ''
            )
          )
          .digest('base64')
          .replace(/\//g, '')
      },
      priority: 5,
      minChunks: 2,
      reuseExistingChunk: true,
    },
  },
  maxInitialRequests: 20,
 }
}
return config;
}
}

This is the error I'm getting after next build Error

> Build error occurred
Error: Cannot find module for page: /404
at pageNotFoundError (/Users/vigraman/Projects/ulp-web/node_modules/next/dist/next- 
server/server/require.js:1:384)
at getPagePath (/Users/vigraman/Projects/ulp-web/node_modules/next/dist/next- 
server/server/require.js:1:917)
at /Users/vigraman/Projects/ulp-web/node_modules/next/dist/build/index.js:15:3168
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Promise.all (index 0)
at async build (/Users/vigraman/Projects/ulp- 
web/node_modules/next/dist/build/index.js:15:2729) {
code: 'ENOENT'
}
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Vicky
  • 31
  • 6

0 Answers0