Schotsl/Uwuifier

"Uwuifier is not a constructor" at node version 18.9.0

Closed this issue · 7 comments

This is in regard to #65

But this is a very weird issue, because I don't seem to have the issue on the Docker container and on my old Windows installation.
So I did a little digging and found out that it might be an issue with the node version.

  • I was trying version 4.0.4 (also running on the server) and now version 4.0.5.
  • Server is running node:current-buster-slim which is, according to Docker Hub, 18.9.0. But because the container is a little dated, it runs 18.5.0.
  • Then I made separate containers with 18.9.0 and this issue pops up.
  • I also have the same issue on my Dev-station running version 18.9.0.

Is there any way to fix this other than reverting to previous node versions?

And yes, I'm aware that the package is pushing import/export, but most of the other packages are still commonJS...
But it does work… Just not with that little bit of version difference.

What is provided in the "type" variable of your package.json?

This is a ES module. Your project should be a ES module for it to work properly.

Regarding the other packages still being commonJS, an ES module project will be able to import commonJS modules.
An example can be found here: https://codesandbox.io/s/wandering-glitter-etq85n?file=/src/index.js

If you are able, please provide (part of) your source repository for more detailed assistance.

I am not using ES Module. The suggested method doesn't work with discord.js, unless I'm doing something wrong and don't quite understand this editor?
https://codesandbox.io/s/wonderful-browser-1r558f?file=/src/index.js

discord.js works with these imports.

Here is an example index.js file using both Discord.JS and Uwuifier.

index.js

import { IntentsBitField } from "discord.js"
import Uwuifier from "uwuifier"

const uwu = new Uwuifier();

const intents = new IntentsBitField([
    IntentsBitField.Flags.Guilds,
    IntentsBitField.Flags.GuildMessages
  ]);

console.log(intents);
// IntentsBitField { bitfield: 513 }

console.log(uwu.uwuifySentence("Some epic package making this sentence all uwu!"));
// Some epic package making this sentence aww uwu?!!

package.json

"type": "module"

Node version: v18.9.1

Yea, I just tested it as well. It wasn't always like that, tho. Might take some time to switch it out in the bot.

This issue is resolved then? :)

Yea. After thinking about it, ill opt for using version 4.0.4 on node 18.5.0 as changing it would require a lot of framework changes what I cant do at the moment.