MatthewWid / better-sse

⬆ Dead simple, dependency-less, spec-compliant server-sent events implementation for Node, written in TypeScript.
MIT License
485 stars 14 forks source link

SyntaxError with 'better-sse' package #60

Closed Pos-cmd closed 5 months ago

Pos-cmd commented 5 months ago

### Description: I encountered a SyntaxError while attempting to import the 'better-sse' package in my project. The error specifically states:

SyntaxError: The requested module 'better-sse' does not provide an export named 'createSession'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

### Problem: Despite having the 'better-sse' package installed, I'm unable to utilize the 'createSession' export, which is essential for my project.

### Environment: Operating System: Windows 10 Package Manager: pnpm Node version: 18 Steps to Reproduce: Install 'better-sse' package using pnpm. Import 'better-sse' and attempt to use 'createSession' export. Expected Behavior: I expected to be able to import and use the 'createSession' export from the 'better-sse' package without encountering a SyntaxError.

### Actual Behavior: The SyntaxError mentioned above occurs when attempting to import 'better-sse'.

### Additional Information: I have verified that the package is correctly installed. My project relies on this functionality, so resolving this issue is crucial.

MatthewWid commented 5 months ago

Do you have a minimal reproduction repo? I can't seem to reproduce this, also on Windows 10 and Node 18.

Perhaps there is an issue with your build system being unable to import CommonJS named exports. In that case you can try using the default export instead:

import sse from "better-sse";
const { createSession } = sse;
Pos-cmd commented 5 months ago

Thank you this work well mow.