Closed Corentin7301 closed 1 year ago
Hi @Corentin7301 , could you check :
https://github.com/kevinmarrec/marrec.io It's deployed on https://marrec.io using latest version of the module, without issues.
Let me know if there's anything in your configuration that could alter the result.
Thanks for your answer! I tested your repo, it works well. So I've used your PWA configuration, I've updated Nuxt to rc-11, my SSR is turn to false, but I always have this error in Lighthouse... I don't think it's a Lighthouse problem because it worked fine for your repo...
If you like check my config: https://github.com/Corentin7301/wildcount/tree/feature/v2
I don't really see something wrong, I also tried my website with ssr: false
and it still works.
Did you try again with Nuxt RC 11 ? Also, could you provide the expanded errors of Lighthouse checks ? (expand the red checks with the arrows and do another screenshot) Thanks
Also, can you try adding a name
field in your package.json
? I remember similar issue cause it's used for some default values in the PWA module.
I tried few more things, I can't find the issue, except you're deploying your website on something like Github Pages or something which is not at root.
To give you more context, start_url
needs to match the route your website lives so that the PWA can control it.
start_url
default is :
https://github.com/kevinmarrec/nuxt-pwa-module/blob/0620153d5a0f8472c8a35cf22d84a4213a1de062/src/module.ts#L28
So to fix your problem, you may need to change app.baseURL
which default to /
.
See : https://v3.nuxtjs.org/api/configuration/nuxt-config#baseurl
Also, can you try adding a
name
field in yourpackage.json
? I remember similar issue cause it's used for some default values in the PWA module.
I've tested with name in package.json
but I've the same error.
Please look expanded Lighthouse errors:
And I use now Nuxt rc-11.
I deploy my website on Netlify and I deploy the dist
folder with npm run build
command.
So to fix your problem, you may need to change
app.baseURL
which default to/
.
Yes, but what do I change my app.baseUrl
by what?
@Corentin7301 Is your website public ? I'd like to take a look to investigate what is published, so I can find what's missing when deployed.
Yes!
Here is the website url : https://app.wildcount.fr/
And the repo is https://github.com/Corentin7301/wildcount/tree/feature/v2 (Be careful to be well on the branch feature/v2
)
Thank you very much for your time!
Alright thanks, I'll take a closer look later today !
Thank you very much!
@Corentin7301 Unfortunately, I'm not able to start your project after installing dependencies :
Am I missing something ?
EDIT: I think I missed a pnpm
hoist configuration during install, my bad.
Alright I found the issue but I don't have the fix yet.
Following the code here :
https://github.com/kevinmarrec/nuxt-pwa-module/blob/0620153d5a0f8472c8a35cf22d84a4213a1de062/src/parts/workbox/index.ts#L32-L38
The Service Worker is never registered cause load
event on window
does not fire the same way when ssr
is false
.
I may need extra help of the Nuxt Framework team to debug this.
One more update regarding this one, well this is only happening when using pages
folder + ssr: false
.
When ssr
is true
, there is no problem cause the script containing Service Worker registration is already in the HTML served.
When ssr
is false, the script will be injected later, and when not using pages
, your app is lighter so I guess it injects it enough fast to make it work.
Finally, when using pages
with ssr: false
, well unfortunately the load
event fired before the event listener has been added, so the service worker is never registered.
The latter can be confirmed by doing navigator.serviceWorker.register('/sw.js')
in the browser console.
Oh okay! I understand! Thanks for your very good explanation!
Here's how we implemented in color-mode module: https://github.com/nuxt-modules/color-mode/pull/164
@danielroe Thank you mate !
@Corentin7301 I'll work on it soon
Fixed & Released on v0.7.0 ✨
Please give it a try @Corentin7301 !
@kevinmarrec Unfortunately I've a error 500 in production.
Netlify Build Logs:
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async $fetchRaw2 (./node_modules/ohmyfetch/dist/shared/ohmyfetch.c2a48baf.mjs:132:20)
4:55:40 PM: at async Object.errorhandler [as onError] (./.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:342:29)
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:545:9)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async $fetchRaw2 (./node_modules/ohmyfetch/dist/shared/ohmyfetch.c2a48baf.mjs:132:20)
4:55:40 PM: at async Object.errorhandler [as onError] (./.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:342:29)
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:545:9)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async $fetchRaw2 (./node_modules/ohmyfetch/dist/shared/ohmyfetch.c2a48baf.mjs:132:20)
4:55:40 PM: at async Object.errorhandler [as onError] (./.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:342:29)
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:545:9)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async $fetchRaw2 (./node_modules/ohmyfetch/dist/shared/ohmyfetch.c2a48baf.mjs:132:20)
4:55:40 PM: at async Object.errorhandler [as onError] (./.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:342:29)
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:545:9)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async $fetchRaw2 (./node_modules/ohmyfetch/dist/shared/ohmyfetch.c2a48baf.mjs:132:20)
4:55:40 PM: at async Object.errorhandler [as onError] (./.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:342:29)
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:545:9)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
4:55:40 PM: [error] [nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
4:55:40 PM: at ./node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs:8:86
4:55:40 PM: at ./node_modules/hookable/dist/index.mjs:39:70
4:55:40 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:427:3
4:55:40 PM: at async ./.nuxt/prerender/chunks/renderer.mjs:52:22
4:55:40 PM: at async ./node_modules/h3/dist/index.mjs:592:19
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async $fetchRaw2 (./node_modules/ohmyfetch/dist/shared/ohmyfetch.c2a48baf.mjs:132:20)
4:55:40 PM: at async Object.errorhandler [as onError] (./.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:342:29)
4:55:40 PM: at async nodeHandler (./node_modules/h3/dist/index.mjs:545:9)
4:55:40 PM: at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
4:55:40 PM: at async generateRoute (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2691:17)
4:55:40 PM: at async prerender (./node_modules/nitropack/dist/shared/nitro.9c828268.mjs:2737:22)
4:55:40 PM: at async ./node_modules/nuxt/dist/index.mjs:1429:7
4:55:40 PM: at async build (./node_modules/nuxt/dist/index.mjs:2000:5)
4:55:40 PM: at async Object.invoke (./node_modules/nuxi/dist/chunks/build.mjs:47:5)
4:55:40 PM: at async _main (./node_modules/nuxi/dist/cli.mjs:50:20)
EDIT: In devlopement mode, I've:
ERROR Cannot start nuxt: Cannot find module './module.json'
Require stack:
- /Users/corentinperroux/Documents/dev/projets/wildcount/node_modules/@nuxtjs/tailwindcss/dist/module.cjs
@Corentin7301 Thank your for the feedback, I've been running tests locally but well, when it's published on npm and then installed it's not exactly the same environment. Gonna find a fix
@Corentin7301 You should have better luck with v7.0.1 😉
Sorry for the broken v0.7.0.
@kevinmarrec Thanks for your fast answer!
I've a new build error:
5:22:19 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
5:22:17 PM: [error] Package import specifier "#imports" is not defined in package /opt/build/repo/node_modules/@kevinmarrec/nuxt-pwa/package.json imported from /opt/build/repo/node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs
5:22:17 PM: at new NodeError (node:internal/errors:387:5)
5:22:17 PM: at throwImportNotDefined (node:internal/modules/esm/resolve:453:9)
5:22:17 PM: at packageImportsResolve (node:internal/modules/esm/resolve:836:3)
5:22:17 PM: at moduleResolve (node:internal/modules/esm/resolve:994:21)
5:22:17 PM: at defaultResolve (node:internal/modules/esm/resolve:1214:11)
5:22:17 PM: at nextResolve (node:internal/modules/esm/loader:165:28)
5:22:17 PM: at ESMLoader.resolve (node:internal/modules/esm/loader:844:30)
5:22:17 PM: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:18)
5:22:17 PM: at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
5:22:17 PM: at link (node:internal/modules/esm/module_job:75:36)
@Corentin7301 That's weird, I updated my website with 0.7.1 and didn't encounter this issue :(
Sounds like to be at netlify build level
@kevinmarrec Okay, I'll try again.
@Corentin7301 Alright, also check locally build
+ start
if you have any errors this way as well :)
@kevinmarrec Effectively the build breaks on Netlify with the same Package import specifier "#imports" is not defined in package /opt/build/repo/node_modules/@kevinmarrec/nuxt-pwa/package.json imported from /opt/build/repo/node_modules/@kevinmarrec/nuxt-pwa/dist/runtime/nitro-plugin.mjs
error...
@Corentin7301 Alright, also check locally
build
+start
if you have any errors this way as well :)
No problem in local...
@Corentin7301 Do you have any idea what package manager uses Netlify and which version ?
@kevinmarrec I'm sorry but I don't know...
@Corentin7301 No problem, I'll take more time to investigate and hopefully find a fix
@kevinmarrec Okay, I hope you will find a fix! Thank you very much for your work!
@Corentin7301 Alright it's when using nuxi generate
! I have a fix
@Corentin7301 Please have one more try with v0.7.2 🤞
@kevinmarrec Okay, build is correct!
@kevinmarrec And PWA is working!!! Just the time of PWA install is a little long... but I don't think it is the module fault.
Thank you very much for your time, your fix and your module! 🚀
@Corentin7301 Glad to know it's finally working for you :)
Hello! I've update the module to
0.6.1
and I've always the same error of #32 issue...It's strange because when I look at the services workers in the browser, it appears well...
I was able to install the application on a mobile but the installation time was very long and not natural...
I didn't get the notification either, I had to install it manually.
Here are some screenshots of the worker service in the browser and the return of Lighthouse: