useplunk / node

Helper library for interacting with Plunk in Node.js
https://www.npmjs.com/package/@plunk/node
20 stars 4 forks source link

Plunk is not a constructor #2

Open awdr74100 opened 1 year ago

awdr74100 commented 1 year ago

螢幕擷取畫面 2023-10-23 154902

repo: https://github.com/awdr74100/plunk-demo

I found that someone also raised this issue on discord, and they all happened to use Nuxt (Nitro) to build the backend. I can't confirm which side the problem is.

It would be great if this could be fixed! Any help is greatly appreciated!

awdr74100 commented 1 year ago

Hi, I think the problem comes from the fact that the module is based on CommonJS instead of ESM, so Nuxt (Nitro) and other projects with the "type": "module" attribute cannot be loaded smoothly.

A simple fix is:

import Plunk from "@plunk/node";

const key = "..."
const plunk = new Plunk.default(key); // but typescript will prompt an error
driaug commented 1 year ago

Hey there! Sorry for missing this issue!

We are in the process of rewriting some of our open-source components so this issue will be resolved quite soon!

jasongitmail commented 3 months ago

This should probably be highlighted in the README. Spent time troubleshooting it too. Thanks for the fix @awdr74100 Works well with that