[英]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.