Npm run generate runs locally but not on Netlify

Hello, I’m using Nuxt.js to develop a website and following it’s guide to deploy static files to Netlify, which is listed below.

  1. Branch to deploy: master , or which-ever branch you prefer
  2. Build command: npm run generate
  3. Publish directory: dist

I know that I can generate the files locally and then drag and drop but that reduces my workflow automation. The generate command works locally I’m not sure why it doesn’t work here.

The main error from the logs:

1:26:30 PM:  FATAL  (intermediate value).flat is not a function
1:26:30 PM:   at prepareFonts (node_modules/nuxt-font-loader-strategy/lib/utils/**fontFace.js:56:8**)
1:26:30 PM:   at process._tickCallback (internal/process/next_tick.js:68:7)
1:26:30 PM:   at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
1:26:30 PM:   at startup (internal/bootstrap/node.js:283:19)
1:26:30 PM:   at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
1:26:30 PM:    ╭────────────────────────────────────────────────────────────╮
1:26:30 PM:    │                                                            │
1:26:30 PM:    │   ✖ Nuxt Fatal Error                                       │
1:26:30 PM:    │                                                            │
1:26:30 PM:    │   TypeError: (intermediate value).flat is not a function   │
1:26:30 PM:    │                                                            │
1:26:30 PM:

Since the error is in a file that’s in a file that is being downloaded by Netlify I don’t know how to fix it. I was thinking about uploading the folder node_modules to the repository but that seems to be bad practice

Here’s the link to my deploys:

Some points to note. I tried:

  • Clearing cache
  • Opening a new site and trying to deploy from there
  • Ensuring that package-lock.json was not in my repo (it used to be then I removed it and tried the build again)
  • Changing the build image to trusty
  • Using yarn generate //Just to try it, it failed as expected anyway

I got it! Forced the build process to use the latest version of Node.js by add an environment variable