I am learning javascript and svelte and I have found a module that I want to use. The issue is that the module is built for node, so I can't directly use it on client side with require('number-to-words')
.
I've installed the package nonetheless and I tried importing it with
import { toOrdinalWord } from 'number-to-words'
with no success.
I was looking at solutions like browserify and requirejs but they seem a bit too complicated/convoluted for the simple library I am trying to use and I'm confused as to how to use them with Svelte(kit) specifically.
What should I do to somehow make a call to that library on client-side?
The browser has built-in helper utilities for handling these conversions. Have a look at MDNs docs to see if you find what you need in the Intl API. Notably, when it comes to handling ordinal numbers check the link below.