d3xter-dev / sitemap-module-nuxt-3

Sitemap Module for Nuxt 3
https://sitemap.nuxtjs.org
MIT License
63 stars 12 forks source link

Static page build on Render.com fails with "ctx.route.replaceAll is not a function" #25

Closed vanekj closed 1 year ago

vanekj commented 1 year ago

Hello!

I am having issues generating static website on Render.com after configuring this sitemap module. It works with no issues on my local machine. Could you please help me with that? Thank you 🙏🏻

nuxt.config.ts

modules: [
  ['@funken-studio/sitemap-nuxt-3', {
    generateOnBuild: true,
    hostname: 'https://domain.com',
    gzip: true,
  }],
],

Build Command: npm run generate (nuxt generate) Publish Directory: .output/public Build log:

Jan 12 05:43:19 PM  ℹ Client built in 6772ms
Jan 12 05:43:19 PM  ℹ Building server...
Jan 12 05:43:23 PM  ✔ Server built in 4058ms
Jan 12 05:43:23 PM  ✔ Generated public .output/public
Jan 12 05:43:23 PM  ℹ Initializing prerenderer
Jan 12 05:43:25 PM  ℹ Prerendering 6 initial routes with crawler
Jan 12 05:43:25 PM    ├─ / (135ms)
Jan 12 05:43:25 PM    ├─ /page-1 (22ms)
Jan 12 05:43:25 PM    ├─ /page-2 (19ms)
Jan 12 05:43:25 PM    ├─ /page-3 (19ms)
Jan 12 05:43:25 PM  
Jan 12 05:43:25 PM   ERROR  ctx.route.replaceAll is not a function
Jan 12 05:43:25 PM  
Jan 12 05:43:25 PM    at node_modules/@funken-studio/sitemap-nuxt-3/dist/module.mjs:419:92
Jan 12 05:43:25 PM    at node_modules/hookable/dist/index.mjs:39:82
Jan 12 05:43:25 PM    at async prerender (node_modules/nitropack/dist/shared/nitro.c8278d90.mjs:2961:7)
Jan 12 05:43:25 PM    at async node_modules/nuxt/dist/index.mjs:1675:7
Jan 12 05:43:25 PM    at async build (node_modules/nuxt/dist/index.mjs:2236:5)
Jan 12 05:43:25 PM    at async Object.invoke (node_modules/nuxi/dist/chunks/build.mjs:56:5)
Jan 12 05:43:25 PM    at async Object.invoke (node_modules/nuxi/dist/chunks/generate.mjs:32:5)
Jan 12 05:43:25 PM    at async _main (node_modules/nuxi/dist/cli.mjs:50:20)
Jan 12 05:43:25 PM  
Jan 12 05:43:26 PM  npm ERR! code ELIFECYCLE
Jan 12 05:43:26 PM  npm ERR! errno 1
Jan 12 05:43:26 PM  npm ERR! @ generate: `nuxt generate`
Jan 12 05:43:26 PM  npm ERR! Exit status 1
Jan 12 05:43:26 PM  npm ERR!
Jan 12 05:43:26 PM  npm ERR! Failed at the @ generate script.
Jan 12 05:43:26 PM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Jan 12 05:43:26 PM  
Jan 12 05:43:26 PM  npm ERR! A complete log of this run can be found in:
Jan 12 05:43:26 PM  npm ERR!     /opt/render/.cache/_logs/2023-01-12T16_43_26_067Z-debug.log
Jan 12 05:43:26 PM  ==> Build failed 😞
StefanVDWeide commented 1 year ago

Running into the same issue. Have you found a solution for this?

StefanVDWeide commented 1 year ago

Okay, found the root cause and the solution. Render.com uses Node version 14.17.0 when you don't specify something yourself. The replaceAll function was introduced in version 15 if I'm not mistaken. So, in order to resolve this you need to create a file in the root of your directory called .node-version and add a single line saying lts. You can find more details here

Hope this helps!

vanekj commented 1 year ago

@StefanVDWeide Good point! Works for me as well with the .node-version file. Thank you for resolving this. I am closing this one as according the Nuxt 3 docs, we should be using 16.x version.