I just installed this package, which by the way, seems to be the only one that does truncation and is currently maintained.
However, I have an issue while using this package inside my Next.Js application (in Typescript).
Here is how I import the package :
import cliTruncate from "cli-truncate";
// I also tried
import * as cliTruncate from "cli-truncate";
And here is the error on runtime:
Error: Must use import to load ES Module: D:\workspace\my-app\node_modules\cli-truncate\index.js
require() of ES modules is not supported.
require() of D:\workspace\my-app\node_modules\cli-truncate\index.js from D:\workspace\my-app\packages\website\.next\server\pages\blog.js 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 D:\workspace\my-app\node_modules\cli-truncate\package.json.
Hello,
I just installed this package, which by the way, seems to be the only one that does truncation and is currently maintained.
However, I have an issue while using this package inside my Next.Js application (in Typescript).
Here is how I import the package :
And here is the error on runtime:
Do you have any idea why is this happening?