简体   繁体   English

错误:找不到模块“节点:fs/promises”(下一个站点地图)

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

next-config.js下一个配置.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": "^2.1.15",

next-sitemap.js下一个站点地图.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 .在上面你可以看到,当我尝试使用next-sitemap创建站点地图时,我找到了将fs添加到next-config.js文件的解决方案,对于webpack 5 But it show me next issue.但它告诉我下一个问题。 How can I fix it?我该如何解决?

node -v
v14.16.0

In my case, I was able to solve this problem by simply increasing the node version:就我而言,我可以通过简单地增加节点版本来解决这个问题:

v14.17.0` -> `v16.14.2

I'm facing the same issue in Node v12.22.12.我在 Node v12.22.12 中面临同样的问题。

I have solved issue by updating the Node version to v14.18.0我通过将节点版本更新到v14.18.0解决了问题

So please update the Node version to v14.18.0 or more所以请将 Node 版本更新到v14.18.0或更高版本

I solved this problem by upgrading my node version to v16.17.0.我通过将节点版本升级到 v16.17.0 解决了这个问题。 Also, take a look at this solution.另外,看看这个解决方案。 [1]: Module not found: Can't resolve 'fs' in Next.js application [1]: 找不到模块:无法解析 Next.js 应用程序中的“fs”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 下一个站点地图的动态站点地图 - Dynamic sitemap by next-sitemap 即使我仅在“getStaticProps()”中使用 fs 代码,也找不到模块“fs/promises” - 下一个 js - Cannot find module 'fs/promises' even when I use the fs code only inside "getStaticProps()" - next js NextJs 应用程序错误,同时创建 Api Routes import * as fs from 'node:fs/promises'; SyntaxError: 不能在模块外使用 import 语句 - NextJs app error while creating Api Routes import * as fs from 'node:fs/promises'; SyntaxError: Cannot use import statement outside a module 无法在 Vercel + Next js 上部署 next-sitemap - Can't deploy next-sitemap on Vercel + Next js 解析错误:找不到模块“next/babel” - Parsing error: Cannot find module 'next/babel' 解析错误:找不到模块“next/babel” - Parsing error : Cannot find module 'next/babel' Next.js + eslint:无法解析模块“fs/promises”的路径 - Next.js + eslint: unable to resolve path to module 'fs/promises' 错误:找不到模块 '/next'、docker、next.js - Error: Cannot find module '/next', docker, next.js 错误:在 next.js 中找不到模块“swiper/react” - Error: Cannot find module 'swiper/react' in next.js Netlify Next.js 部署错误:找不到模块“esbuild” - Netlify Next.js deploy error: Cannot find module ‘esbuild’
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM