Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module 'node:fs/promises' (next-sitemap)

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
like image 204
Andrey Radkevich Avatar asked Nov 23 '25 20:11

Andrey Radkevich


1 Answers

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

like image 113
Milan Katariya Avatar answered Nov 26 '25 09:11

Milan Katariya