Postbuild opening config file instead of running next-sitemap
See original GitHub issueHi!
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:
- Created 3 years ago
- Reactions:2
- Comments:31 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
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: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.