2

next-config.js

/** @type {import('next').NextConfig} */
module.exports = {
  i18n: {
    locales: ['en', 'ru'],
    defaultLocale: 'en',
  },
  publicRuntimeConfig: {
    API_URL: process.env.API_URL,
  },
  images: {
    domains: ['fakestoreapi.com'],
  },
  trailingSlash: true,
  webpack: (config, { isServer }) => {
    const newConfig = { ...config };

    if (!isServer) {
      newConfig.resolve.fallback.fs = false;
    }
    return newConfig;
  },
};

Next sitemap version - "next-sitemap": "^2.1.15",

next-sitemap.js

/** @type {import('next-sitemap').IConfig} */

module.exports = {
  siteUrl: 'https://box.hedgefun.net/',
  generateRobotsTxt: true,
};

Above you can see as I try to use next-sitemap for creating sitemap , I've found solution to add fs to next-config.js file, for webpack 5 . But it show me next issue . How can I fix it ?

node -v
v14.16.0
Andrey Radkevich
  • 3,012
  • 5
  • 25
  • 57

3 Answers3

2

I'm facing the same issue in Node v12.22.12.

I have solved issue by updating the Node version to v14.18.0

So please update the Node version to v14.18.0 or more

Milan Katariya
  • 356
  • 1
  • 12
1

In my case, I was able to solve this problem by simply increasing the node version:

v14.17.0` -> `v16.14.2
Mario Boss
  • 1,784
  • 3
  • 20
  • 43
K K
  • 73
  • 6
0

I solved this problem by upgrading my node version to v16.17.0. Also, take a look at this solution. [1]: Module not found: Can't resolve 'fs' in Next.js application