Named export 'w3cwebsocket' not found. The requested module 'websocket' is a CommonJS module
See original GitHub issue(Issue reported by @jonnyparris and others in https://github.com/nuxt/framework/issues/6495)
Version
@nuxtjs/supabase: 0.1.19 nuxt: 3.0.0-rc.8
Reproduction Link
https://github.com/jonnyparris/bug-repro-nuxt3
Steps to reproduce
yarn generate
(oryarn build
and start server)
What is Expected?
What is actually happening?
Runtime fails with importing websocket
which is an incompatible CommonJS package used by @supabase/supabase-js
> @supabase/realtime-js
Solution
Quick workaround: (updated with solution of @matthewmaribojoc in https://github.com/nuxt/framework/issues/6495#issuecomment-1215159091)
import { defineNuxtConfig } from 'nuxt'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
build: {
transpile: [process.env.NODE_ENV === 'production' ? 'websocket' : ''],
}
})
There are several other solutions we can consider and I probably add a CJS fix to unenv that fixes this magically but I spotted we are using a library that is probably never used in server (SSR and Nitro) @supabase/realtime-js
. We could avoid using supabase client in server by direct API or mock this specific module only for server.
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top GitHub Comments
UPDATED: Should be fixed in v0.1.23
Thanks for the reproduction @mwohlan, indeed there was still an error on dev mode, it should be fixed in
0.1.23
! Hope you confirm it’s good for you 👍