Next-Sitemap“错误:预期&#x27 ;;'在Windows 11上
尝试使用NextSitemap为我的下一个JS网站制作站点地图。从我的研究中,如果不包括交叉ENV,临时Sitemap在Windows上无效。关于该怎么做的任何建议?
我目前将我的后建筑命令设置为:
"postbuild": "cross-env next-sitemap --config next-sitemap.js""postbuild": "cross-env next-sitemap --config next-sitemap.js"
这是我的sext-sitemap.js:
let policy = {
userAgent: "*",
};
if (process.env.ENVIRONMENT !== "production") {
policy.disallow="/";
};
module.exports = {
siteUrl: process.env.URL,
generateRobotsTxt: true,
robotsTxtOptions: {
policies: [
policy
],
},
outDir: "./out"
}
Trying to get a sitemap made for my Next JS site using next-sitemap. From my research, next-sitemap doesn't work on Windows without including cross-env. Any suggestions on what to do?
I currently have my postbuild command set to:
"postbuild": "cross-env next-sitemap --config next-sitemap.js""postbuild": "cross-env next-sitemap --config next-sitemap.js"
And here is my next-sitemap.js:
let policy = {
userAgent: "*",
};
if (process.env.ENVIRONMENT !== "production") {
policy.disallow="/";
};
module.exports = {
siteUrl: process.env.URL,
generateRobotsTxt: true,
robotsTxtOptions: {
policies: [
policy
],
},
outDir: "./out"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,在此YouTube视频上,他的跨性别NPM运行npm run构建(或纱线构建)对他来说是一样的,他这样做了:
https://www.youtube.com/watch?v=zs-6oiwvnnc
我不认为您需要Cross-env,但是对于Windows来说,您必须做的是改为更改文件名。 请参阅此处的文档。
Tryp running npm run build (or yarn build) first, on this youtube video happened the same to him and he did it like that:
https://www.youtube.com/watch?v=zS-6oiwvNnc
I don't think you need the cross-env, but for windows what you have to do is changing the file name instead. See the docs here.
对我而言,将最终名称上的前缀配置设置为sextsitemap文件(next-sitemap-config.js)和script.json on script
next-sitemap -config next-config next-sitemap-config.js
。For me worked, set the next-sitemap files with the prefix config on the final name (next-sitemap-config.js) and in package.json on script
next-sitemap --config next-sitemap-config.js
.