I am trying to use this package in a typescript project, using ts-node to execute, my code is literally only this:
import filenamify from "filenamify"
console.log(filenamify('<file123>'))
then I execute it. using the following command:
npx ts-node src/test.ts
and then the following error get displayed:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/user1/test-projects/test-filenamify/node_modules/filenamify/index.js
require() of ES modules is not supported.
require() of /Users/user1/test-projects/test-filenamify/node_modules/filenamify/index.js from /Users/user1/test-projects/test-filenamify/src/test.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/user1/test-projects/test-filenamify/node_modules/filenamify/package.json.
I have tried using dynamic import. and require. and I was not able to make it work, if you execute it using runkit, it also have a similar error https://npm.runkit.com/filenamify
Hello,
I am trying to use this package in a typescript project, using ts-node to execute, my code is literally only this:
then I execute it. using the following command:
and then the following error get displayed:
I have tried using dynamic import. and require. and I was not able to make it work, if you execute it using runkit, it also have a similar error https://npm.runkit.com/filenamify