Support Forums

Nuxt2 (Bridge) generate command with Nuxi CLI fails on Netlify but not locally

I have a new Nuxt2 project with target: static (SSG) upgraded to Nuxt Bridge in order to use Vue3 syntax, Vite and most of the Nuxt3 features.

The build command npm run generate runs successfully on my own system with Node 14.17.3. This script triggers “nuxi generate” as seen in my package.json below.

On Netlify deploy the generate script seems to fail because it cannot find Nuxi (?).

My package.json contents:

  "scripts": {
    "dev": "nuxi dev",
    "build": "nuxi build",
    "start": "node .output/server/index.mjs",
    "generate": "nuxi generate"
  "dependencies": {
    "@nuxt/kit": "npm:@nuxt/kit-edge@^3.0.0-27277498.850ef69",
    "@nuxtjs/i18n": "^7.2.0",
    "core-js": "^3.15.1",
    "nuxt-edge": "latest"
  "devDependencies": {
    "@intlify/vue-i18n-loader": "^1.1.0",
    "@nuxt/bridge": "npm:@nuxt/bridge-edge@^3.0.0-27277498.850ef69",
    "hgrid-css": "^0.7.1-beta",
    "sass": "^1.43.4",
    "sass-loader": "^10.1.1"

Netlify error output:

3:09:23 PM: $ npm run generate
3:09:23 PM: > my-project-name@1.0.0 generate
3:09:23 PM: > nuxi generate
3:09:23 PM: [log] Nuxt CLI v3.0.0-27277498.850ef69
3:09:27 PM: [error] ENOENT: no such file or directory, open '/opt/build/repo/.nuxt/tsconfig.json'
3:09:27 PM: ​
3:09:27 PM: ────────────────────────────────────────────────────────────────
3:09:27 PM:   "build.command" failed                                        
3:09:27 PM: ────────────────────────────────────────────────────────────────
3:09:27 PM: ​
3:09:27 PM:   Error message
3:09:27 PM:   Command failed with exit code 1: npm run generate

I have tried to set NODE_VERSION in Netlify to 12, 14.17.3 and 16, same result for all of them.

Not sure why the .ts file is included in the error message, I use only JS and don’t have a tsconfig file.

Is this related to the ongoing deploy issue here: Netlify Build Failing · Issue #1826 · nuxt/framework · GitHub ?

Do I have to include the nuxi cli in package.json somehow? Thanks for any tips!

EDIT: Site name on Netlify is vigilant-mirzakhani-81ea8b

Hi @elhansson

It appears from the issue you linked this is possibly now fixed. Could you check the thread and try again.

If still no luck, could you changing the build command to from

nuxi generate


nuxi build && nuxi generate

and try building again.

@coelmay Thanks for helping out! I tested your other fix with my Nuxt 3 app that also got stuck the last few days, and that worked out fine now. But the Nuxt 2 Bridge app I’m working on did still not build correctly.

nuxi build && nuxi generate fails with the message “Please use nuxt generate for static target”

Which is contrary to the Nuxt Bridge documentation, where it is explicitly explained that nuxt generate should be replaced with nuxi generate. I now reverted to use nuxt generate and it builds perfectly. (It still seems to be a Netlify issue that prevents nuxi generate from working.)

I was able to get nuxi build && nuxi generate to build (in fact it was the only method I tried that did build successfully).
Even setting target: 'static' (which the build log told me to do) and using nuxi generate failed.

Unfortunately as I am using node.js v16.10.0 and not v16.11.0 as required by nuxt3, I cannot test locally (though it happily built on v16.13.0 on Netlify so I don’t know.)

I forgot that I had set node version to 14.17.3 so I removed that and tried building with nuxi build && nuxi generate on Node 16.13.0, but still fails. No problem as long as it works with the Nuxt 2 command nuxt generate.

P.S. Nuxi generate works fine with Nuxt 3 on Netlify after the fix today. There must be a difference between how Nuxt 2 + Bridge edge uses nuxi and how Nuxt 3 uses it, that makes it fail on the former.