Schotsl / Uwuifier

This repository contains the Uwuifier package! It's written in Deno with TypeScript and compiled into JavaScript for NPM, makes use of Jest for testing the code and is deployed on NPM and https://deno.land.
https://uwuifier.com
MIT License
110 stars 7 forks source link

"Uwuifier is not a constructor" #65

Closed raphaelsiz closed 2 years ago

raphaelsiz commented 2 years ago

So I installed the package the normal way (bc I was getting errors tryna require from the Deno link) and here are two lines of my code:

const Uwuifier = require('uwuifier');
const uwuifier = new Uwuifier();

When I run my project, I get the error "Uwuifier is not a contructor." I tried console.logging Uwuifier to see what it was counting it as and... it's a class. Surprise surprise. Does anyone know why this would count as a class in the log, but not as a constructor to create an instance of it?

dbrxnds commented 2 years ago

This is because you're using require syntax in a module-only environment. Try import Uwuifier from 'uwuifier'.

https://codesandbox.io/s/thirsty-lamport-969h2j?file=/src/index.ts

raphaelsiz commented 2 years ago

import was throwing errors too bc I'm just using it in a generic nodejs index.js is uwuifier only meant to be used in specific situations? like frameworks etc?

Schotsl commented 2 years ago

I think you're either running the wrong Node.js version or something is misconfigured in your package.json, could you link your repository? :)