Next-Sitemap“错误:预期&#x27 ;;'在Windows 11上

发布于 2025-01-22 17:13:59 字数 814 浏览 2 评论 0原文

尝试使用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"
}

https://i.sstatic.net/ifppg.png“ alt =” sitemaperror“>

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"
}

SitemapError

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海的爱人是光 2025-01-29 17:13:59

首先,在此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.

两个我 2025-01-29 17:13:59

对我而言,将最终名称上的前缀配置设置为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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文