Next.js Discord

Discord Forum

toSorted is throwing error in Runtime

Answered
Ghost ant posted this in #help-forum
Open in Discord
Ghost antOP
I chose to use toSorted for the first time, but I ran into an error, is it too early to use it?
Nextjs v: 14.0.1
`ts
// tsconfig
{
  "compilerOptions": {
    "target": "es2017",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "checkJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
}
Answered by Ray
toSorted is supported in node v20+
View full answer

12 Replies

Answer
Ghost antOP
I could feel it!
Ghost antOP
yes, but I am still using v 18.x
Giant panda
I was correcting Ray because he accidentally phrased it as if it's not available at all in Node.
Offtopic: Anyways, you should consider upgrading to v20 as this is the new LTS.
Ghost antOP
it is still in beta, I prefer to wait till becomes stable
Giant panda
It's LTS ever since October
@Giant panda It's LTS ever since October
Beta as a runtime version on vercel
@Ray `toSorted` is supported in node v20+
I marked this as the sol but could you edit to clarify that toSorted is only available from node 20?