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

Can't construct Uwuifier from npm sources #70

Closed mrowkaadrian closed 10 months ago

mrowkaadrian commented 10 months ago

Hey, I am currently trying to use your Uwuifier in one of my hobby project as a dependency.

I am using this NPM package https://www.npmjs.com/package/uwuifier, because I would rather avoid using Deno.

This is part of my code which is failing:

const myUwuifier = new Uwuifier({
    spaces: {
        faces: 0.5,
        actions: 0.075,
        stutters: 0.1
    },
    words: 1,
    exclamations: 1
});

I am getting following error: TypeError: Uwuifier is not a constructor

wouterdebruijn commented 10 months ago

Hi there,

It seems like you are using the older commonjs import syntax: const Uwuifier = require('uwuifier'); which is not supported. To use this package please update to the newer ESmodule syntax import Uwuifier from "uwuifier";

This requires "type": "module" in your package.json, after which the import "foo" from "bar" syntax should be used for all imports in the project.

import Uwuifier from "uwuifier";

const myUwuifier = new Uwuifier({
    spaces: {
        faces: 0.5,
        actions: 0.075,
        stutters: 0.1
    },
    words: 1,
    exclamations: 1
});

console.log(myUwuifier.uwuifySentence("Hello world!"));
mrowkaadrian commented 10 months ago

Thanks, it will take a while until I refactor all my code to use import syntax, but it maybe worth the while.