3

This is 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.

I run the build command npm run generate successfully on my own system with Node 14.17.3. This script triggers "nuxi generate" (nuxi is the Nuxt3 CLI).

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

Here is the contents of package.json:

  "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

Not sure what the tsconfig.json is doing in the error message, I use plain JS and have no such file.

What do I have to include in order to get Netlify to use or find the Nuxi CLI correctly?

Other tips? Thanks!

anatolhiman
  • 1,762
  • 2
  • 14
  • 23
  • 1
    Found out that the regular Nuxt 2 build command for static sites, `nuxt generate` works fine with my setup, while `nuxi generate` which is the upgraded way to build for Nuxt Bridge/Nuxt 3 does not. It seems like nuxt generate generates a less efficient bundle compared to plain Nuxt 3 (beta) with nuxi generate, the former loads a bit slower with a flash of unstyled content. The "solution" to use the old build command goes contrary to the information given by Nuxt here: https://v3.nuxtjs.org/getting-started/bridge#static-target – anatolhiman Nov 13 '21 at 00:16

1 Answers1

1

With me it also did not work with nuxi generate with bridge: false in nuxt.config.js. But after commenting it out it worked fine. (Documented here: https://v3.nuxtjs.org/getting-started/bridge/#ensure-everything-goes-well)

But with bridge enabled i get this error when running nuxi dev:

WARN  [worker] Invalid or unexpected token  

  at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
  at async link (internal/modules/esm/module_job.js:63:21)

Maybe you also have bridge: false in your nuxt.config.js.

georg
  • 21
  • 5
  • Thanks, @georg I didn't disable bridge in nuxt.config, but it is logical that nuxi doesn't work without bridge, as Nuxi is the newer tool. Very strange that nuxi dev doesn't work for you when bridge is enabled. I didn't get any error messages for that. – anatolhiman Nov 16 '21 at 10:23