【问题标题】:Error: Cannot find module 'node:fs/promises' (next-sitemap)错误:找不到模块“节点:fs/promises”(下一个站点地图)
【发布时间】:2022-04-27 06:56:05
【问题描述】:

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": "^2.1.15",

next-sitemap.js

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

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

您可以在上面看到,当我尝试使用next-sitemap 创建站点地图时,我找到了将fs 添加到next-config.js 文件的解决方案,用于webpack 5。但它告诉我下一个问题。我该如何解决?

node -v
v14.16.0

【问题讨论】:

    标签: next.js sitemap


    【解决方案1】:

    就我而言,我可以通过简单地增加节点版本来解决这个问题:

    v14.17.0` -> `v16.14.2
    

    【讨论】:

      【解决方案2】:

      我在 Node v12.22.12 中遇到了同样的问题。

      我已通过将 Node 版本更新到 v14.18.0

      解决了问题

      所以请将 Node 版本更新到 v14.18.0 或更高版本

      【讨论】:

        猜你喜欢
        • 2021-09-06
        • 2015-10-09
        • 2017-01-08
        • 2023-01-28
        • 1970-01-01
        • 2019-11-05
        • 2021-07-03
        相关资源
        最近更新 更多