caoxiemeihao / nuxt-electron

Integrate Nuxt and Electron
MIT License
187 stars 21 forks source link

Nothing seems to work with run dev, run generate, run build #88

Open liamcharmer opened 1 month ago

liamcharmer commented 1 month ago

Hi. I just started following the nuxt-electron documentation. I first tried yarn dev and it did not work it constantly refreshed the port or something like that.

Doing this solved it for my nuxt config.

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: "2024-04-03",
  devtools: { enabled: true },

  modules: [
    (options, nuxt) => {
      if (!nuxt.options.dev) {
        nuxt.options.nitro.runtimeConfig ??= {};
        nuxt.options.nitro.runtimeConfig.app ??= {};
        nuxt.options.nitro.runtimeConfig.app.baseURL = "./";
      }
    },
    "nuxt-electron",
  ],
  electron: {
    disableDefaultOptions: true,
  },
  ssr: false,
  router: {
    options: {
      hashMode: true,
    },
  },
});

However when trying to run yarn generate or yarn build i get this error;

yarn generate
yarn run v1.22.22
$ nuxt generate
Nuxt 3.13.0 with Nitro 2.9.7                                                                                                                                         21:16:11
ℹ Using Nitro server preset: static                                                                                                                                 21:16:11
ℹ Building client...                                                                                                                                                21:16:13
ℹ vite v5.4.2 building for production...                                                                                                                            21:16:13
ℹ ✓ 130 modules transformed.                                                                                                                                        21:16:13
ℹ .nuxt/dist/client/manifest.json                   1.06 kB │ gzip:  0.29 kB                                                                                        21:16:13
ℹ .nuxt/dist/client/_nuxt/error-500.CIkJDsQj.css    1.88 kB │ gzip:  0.72 kB                                                                                        21:16:13
ℹ .nuxt/dist/client/_nuxt/error-404.DXySnQZL.css    3.56 kB │ gzip:  1.10 kB                                                                                        21:16:13
ℹ .nuxt/dist/client/_nuxt/entry.BRWiKlTd.css       12.40 kB │ gzip:  2.57 kB                                                                                        21:16:13
ℹ .nuxt/dist/client/_nuxt/DAOlUdga.js               2.74 kB │ gzip:  1.23 kB                                                                                        21:16:13
ℹ .nuxt/dist/client/_nuxt/DbDNr14Q.js               8.62 kB │ gzip:  3.46 kB                                                                                        21:16:13
ℹ .nuxt/dist/client/_nuxt/KgBQtgOK.js             215.93 kB │ gzip: 61.93 kB                                                                                        21:16:13
ℹ ✓ built in 718ms                                                                                                                                                  21:16:13
✔ Client built in 726ms                                                                                                                                             21:16:13
ℹ Building server...                                                                                                                                                21:16:13
ℹ vite v5.4.2 building SSR bundle for production...                                                                                                                 21:16:13
ℹ ✓ 1 modules transformed.                                                                                                                                          21:16:13
ℹ .nuxt/dist/server/styles.mjs  0.07 kB                                                                                                                             21:16:13
ℹ .nuxt/dist/server/server.mjs  0.10 kB │ map: 0.22 kB                                                                                                              21:16:13
ℹ ✓ built in 7ms                                                                                                                                                    21:16:13
✔ Server built in 9ms                                                                                                                                               21:16:13

 ERROR  options.build is not iterable                                                                                                                                21:16:13

  at build:done (node_modules/nuxt-electron/dist/index.mjs:71:38)
  at node_modules/hookable/dist/index.mjs:48:66
  at node_modules/hookable/dist/index.mjs:48:56
  at async build (node_modules/nuxt/dist/index.mjs:5532:5)
  at async Object.run (node_modules/nuxi/dist/chunks/build.mjs:102:5)
  at async Object.run (node_modules/nuxi/dist/chunks/generate.mjs:60:5)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.d8541eab.mjs:1648:16)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.d8541eab.mjs:1639:11)
  at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.d8541eab.mjs:1777:7) 

 ERROR  options.build is not iterable                                                                                                                                21:16:13

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

When I run yarn main (as advised by the docs) i get this error;

 yarn main
yarn run v1.22.22
$ dist-electron/main.js
/bin/sh: dist-electron/main.js: Permission denied
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any ideas? Sorry im a bit new to this..

Morten010 commented 5 days ago

how does you're package.json scripts look?