question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 (or yarn 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:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
larbishcommented, Aug 16, 2022

UPDATED: Should be fixed in v0.1.23

1reaction
larbishcommented, Aug 16, 2022

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 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Named export not found. The requested module is a ... - GitHub
js' is a CommonJS module, which may not support all module.exports as named exports. I retried the same thing on a regular svelte...
Read more >
Named export 'Types' not found. The requested module ...
Solution #2. Switch to commonjs , I can keep the import/export syntax in my graphql module and compile it as a cjs module....
Read more >
websocket - npm
Websocket Client & Server Library implementing the WebSocket protocol as ... Start using websocket in your project by running `npm i websocket`.
Read more >
WebSocket - The Modern JavaScript Tutorial
To open a websocket connection, we need to create new WebSocket using the special protocol ws in the url: let socket = new...
Read more >
The WebSocket API (WebSockets) - Web APIs - MDN Web Docs
desktop desktop Chrome Edge WebSocket Full support. Chrome4. Toggle history Full support. Edge12. Toggl... WebSocket() constructor Full support. Chrome4. Toggle history Full support. Edge12. Toggl...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found