question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Postbuild opening config file instead of running next-sitemap

See original GitHub issue

Hi!

I’ve installed next-sitemap (1.2.26) as a dev dependency, and added it to package.json: "postbuild": "next-sitemap".= However, when I build, the postbuild just opens the config file (next-sitemap.js) instead of executing next-sitemap.

Any ideas how to solve this?

Regards, TJ

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:31 (7 by maintainers)

github_iconTop GitHub Comments

14reactions
tomasg88commented, Oct 22, 2021

Hello, Win 10 user over here. I was having the same issue where command postbuild: next-sitemap wouldn’t work.

Solution for me was renaming next-sitemap file and adding config flag, like this: postbuild: next-sitemap --config next-sitemap.config.js

Didn’t need to install cross-env

13reactions
MoltenCoffeecommented, Nov 12, 2020

The immediate cause seems to be the configuration file next-sitemap.js having the same name as the package itself. (With Node ignoring the .js part of course, in contrast with regular Windows behaviour). Node on windows seems to prioritize local files above known values in PATH.

This can be demonstrated by creating a next.js file inside the project directory, and then running the build script (npm run build, next build). It will act the same, trying to open this file instead of running the Next scripts.

Testing a workaround: When I edit next-sitemap/src/path/index.ts to include:

export const KNOWN_PATHS = {
  CONFIG_FILE: getPath('next-sitemap.config.js'),
}

instead of next-sitemap.js, and change the name of the config file accordingly, everything works as intended.

A solution? Of course this package could change its config file, to something like next-sitemap.config.js (which seems to a common format, as it is what Babel, PostCSS, Styleguidist, Next and many others offer (among other options)) but will present a breaking change. Adding it as a secondary config filepath for Windows-users could be an option as well.

I do find it peculiar I don’t seem to be able to find more examples like this online, although I get that developing on Windows might not be the greatest option out there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Make Next-Sitemap Work On Windows
In the postscript command, instead of loading next-sitemap.js , Node on Windows see a folder in the node_modules folder called next-sitemap ...
Read more >
next-sitemap
Start using next-sitemap in your project by running `npm i ... You can also use a custom config file instead of next-sitemap.config.js ....
Read more >
Can't deploy next-sitemap on Vercel + Next js
However, I am getting a deploy error and this is not working. sitemap.config.js (root directory) module.exports = { siteUrl: 'https://example.
Read more >
How To Implement Sitemap in Next Js using next-sitemap
Open your package.json file and add new postbuild scripts as next-sitemap. ... The above code is the minimal configuration for the sitemap.
Read more >
How to Add a sitemap for Static Site Generation (SSG) in ...
For configuration, we create a next-sitemap.js file inside the project folder. ... Do not run the sitemap generate npm run postbuild command directly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found