Skip to content
Nilay Kabariya

Home · Topic · 30 entries

Common Node.js errors, fixed and tested on Node 24

Node keeps changing how modules load, which ports it binds and which crypto it allows, so a fix written for Node 16 can be wrong on Node 24. Each entry below was reproduced on current Node, with the exact version written at the top of the post.

  1. No.051

    Gemini 2.5 Flash "no longer available to new users" (404)

    Code that worked yesterday 404s with a new API key. Every old Gemini model name tested: three different messages, and why the model list won't warn you.

    > {

    AI3 min
  2. No.050

    Gemini API 429 RESOURCE_EXHAUSTED: why your limit is 0

    Gemini's 429 hides three different limits, and one of them never resets. Each hit on purpose with a free key, plus the 503 high demand error.

    > {

    AI4 min
  3. No.049

    Fix: @prisma/client did not initialize yet (Prisma 6 and 7)

    The error says run prisma generate. Why it keeps coming back on Windows, npm 12 and CI, reproduced, plus the errors Prisma 7 throws instead.

    > D:\project\node_modules\.prisma\client\default.js:43

    DATABASE4 min
  4. No.048

    prisma generate not working: "No command registered" (Prisma 8)

    npm now installs a Prisma 8 release candidate as prisma@latest. It has no generate, migrate dev or db push. Reproduced, with the fix for Docker and CI.

    > {"kind":"result","envelope":{"ok":false,"commandId":"","error":{"code":"CLI.UNKNOWN_COMMAND","severity":"error","summary":"No command registered for `generate`","nextActions":[{"kind":"run-command","label":"List every command","command":"prisma --help"}]}}}

    DATABASE4 min
  5. No.046

    Fix: Groq API error 413, 429 and model_not_found

    Groq's 413 and 429 need different fixes. Its old Llama models now just say not found. All three reproduced on the free tier, with the fix for each.

    > 413 Request too large for model `openai/gpt-oss-20b` in organization `org_…` service tier `on_demand` on tokens per minute (TPM): Limit 8000, Requested 30074, please reduce your message size and try again.

    AI4 min
  6. No.045

    Fix: APIConnectionError "Connection error." (OpenAI, Anthropic)

    OpenAI's and Anthropic's SDKs both say only Connection error. Five real causes reproduced, from a local model that isn't running to antivirus HTTPS scanning.

    > APIConnectionError: Connection error.

    AI5 min
  7. No.043

    Vitest 5 migration: breaking changes, tested

    Six behaviours that passed on Vitest 4.1.11 failed or changed on 5.0.3, each with a clear message and a one-line fix. The sneaky one is test.each titles: snapshot keys change, and locally Vitest 5 quietly writes new snapshots instead of failing.

    TESTED4 min
  8. No.042

    Fix: "Could not locate the bindings file" in sqlite3

    sqlite3 or better-sqlite3 installed fine, then can't find its .node file. Four causes reproduced, how the Tried: paths tell them apart, and the fix for each.

    > Error: Could not locate the bindings file. Tried:

    FIXED3 min
  9. No.039

    npm 12 breaking changes, tested: what actually breaks

    The headline change, install scripts blocked by default, broke puppeteer, cypress, sqlite3 and Claude Code's npm package, and silently skipped lefthook's git hooks. esbuild, bcrypt, sharp and better-sqlite3 kept working. Every install reported success, and the only sign was a warning after the summary.

    TESTED5 min
  10. No.036

    Fix: npm error Missing script: "dev" (and "start")

    npm can't find the script you asked for. Six real causes, from a stray package.json up the tree to monorepos, and two commands that show which one you have.

    > npm error Missing script: "dev"

    FIXED5 min
  11. No.032

    Fix: MCP error -32000 Connection closed / Failed to connect

    An MCP server fails with Connection closed or Failed to connect and never says why. Where the real error is hiding, and the fixes, tested in Claude Code.

    > MCP error -32000: Connection closed

    AGENTS3 min
  12. No.031

    TypeScript 7 migration guide: breaking changes, tested

    Every option TypeScript 6.0.3 marked as deprecated was a hard error on 7.0.2, and ignoreDeprecations no longer silences it. Two defaults that arrived in 6.0 (strict on, @types not loaded automatically) also break projects coming straight from 5.9.

    TESTED6 min
  13. No.028

    Fix: Dynamic require of "react" / "fs" is not supported

    esbuild's ES module output throws this for a require() it left in the bundle. Four fixes tested on Node 24, plus the case only Cloudflare Workers hits.

    > throw Error('Dynamic require of "' + x + '" is not supported');

    FIXED3 min
  14. No.025

    Fix: TypeScript enum is not supported in strip-only mode

    Node's ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX for enum, parameter properties, namespace, export = and import =. Two ways to run it unchanged, both tested.

    > enum Color { Red, Green }

    FIXED3 min
  15. No.024

    Fix: Could not resolve authentication method (Anthropic / Claude SDK)

    Anthropic's SDK can't find your key. The old and new wording, ANTHROPIC_API_KEY vs ANTHROPIC_AUTH_TOKEN, and the 401 you get when a key is in the wrong one.

    > Error: Could not resolve authentication method. Expected either apiKey or authToken to be set.

    AI2 min
  16. No.023

    Fix: OpenAI 401 Incorrect API key provided (AuthenticationError)

    OpenAI rejects a key you just copied. How to read which key was really sent from the error itself, why an old key can beat your .env, and the fix.

    > AuthenticationError: 401 Incorrect API key provided: sk-old-s*****************1111.

    AI3 min
  17. No.022

    Fix: typescript-eslint does not support TS 7.0 (ESLint on TS 7)

    When typescript-eslint will support TypeScript 7, why npm refuses the install, and the setup that keeps TypeScript 7 while ESLint runs normally today.

    > npm error code ERESOLVE

    FIXED3 min
  18. No.021

    Fix: The OPENAI_API_KEY environment variable is missing or empty

    OpenAI's SDK or Codex CLI says your key is missing, though it's in .env. Every wording, in JavaScript, Python and Codex, and the fix for each.

    > OpenAIError: The OPENAI_API_KEY environment variable is missing or empty; either provide it,

    AI4 min
  19. No.020

    Upgrading to TypeScript 7? 9 tools tested (ESLint, Jest, ts-node)

    Plain TypeScript 7 broke ts-node, ts-jest, typescript-eslint, TypeDoc and ts-loader, and npm refused to install it at all without a flag. Microsoft's side-by-side setup ran all 9 tools with no errors while tsc stayed on 7.

    TESTED6 min
  20. No.019

    Fix: "Cannot find native binding" in Vite 8 (Rolldown)

    Vite 8 can't find Rolldown's native binding on Windows, WSL or Linux. Why @rolldown/binding-win32-x64-msvc goes missing, and the one-command fix.

    > Error: Cannot find native binding. npm has a bug related to optional dependencies

    FIXED5 min
  21. No.017

    Fix: 'vite' is not recognized as an internal or external command

    Windows says the command doesn't exist, but it's right there in node_modules. The four causes, how to tell them apart in one command, and what each one needs.

    > 'vite' is not recognized as an internal or external command,

    FIXED4 min
  22. No.016

    Fix: Cannot read properties of undefined (reading 'fileExists')

    ts-node and webpack's ts-loader crash with this on TypeScript 7, before your code even runs. Which versions do it, why npm didn't warn you, and four ways out.

    > C:\project\node_modules\ts-node\dist\configuration.js:91

    FIXED3 min
  23. No.015

    Fix: This syntax is not allowed when 'erasableSyntaxOnly' is enabled

    TS1294: TypeScript rejects your enum, namespace or constructor shorthand. Why new projects turn this on, what each piece becomes, and when to switch it off.

    > src/a.ts(1,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.

    FIXED3 min
  24. No.014

    Fix: ERR_MODULE_NOT_FOUND Cannot find module in ES modules

    Node can't find a file that is clearly there. What ES modules changed about relative imports, why TypeScript path aliases break at runtime, and what to change.

    > node:internal/modules/esm/resolve:275

    FIXED2 min
  25. No.013

    Fix: Unknown file extension ".ts" (ERR_UNKNOWN_FILE_EXTENSION)

    Node refuses to run your TypeScript file. The version where this stops happening, what ts-node has to do with it, and the one-line way to run .ts today.

    > node:internal/modules/esm/get_format:189

    FIXED3 min
  26. No.005

    Fix: ERR_REQUIRE_ESM require() of ES Module not supported

    require() of an ES module fails, and on newer Node a different error takes its place. Three fixes, and the trap waiting after you upgrade.

    > Error [ERR_REQUIRE_ESM]: require() of ES Module ...\node_modules\chalk\source\index.js

    FIXED1 min
  27. No.004

    Fix: digital envelope routines::unsupported (ERR_OSSL_EVP_UNSUPPORTED)

    Old webpack 4 builds crash on Node 17+ with 0308010C. A one-line fix that needs no legacy OpenSSL flag and no webpack 5 move. Reproduced on Node 24.

    > Error: error:0308010C:digital envelope routines::unsupported

    FIXED1 min
  28. No.003

    Address already in use on Windows 11? Free the port (EADDRINUSE)

    Windows 11 says the address is already in use, from Node (EADDRINUSE :::3000), Python or anything else. Find what holds the port and free it safely.

    > node:events:486

    FIXED2 min
  29. No.002

    Fix: __dirname is not defined in ES module scope (Node 24)

    Node refuses __dirname in ES modules. The one-line modern fix, the fallback for older Node, and the rename that makes it worse. All run on Node 24.

    > console.log(path.join(__dirname, "data.json"));

    FIXED1 min
  30. No.001

    Fix: “Cannot use import statement outside a module”

    Why Node or your browser refuses import, what changed in Node 24, and the fix for each case. Reproduced in both Node and Chrome.

    > SyntaxError: Cannot use import statement outside a module

    FIXED2 min

Post card · Newsletter

Get the next fix in your inbox.

One short email when a new entry is published. No spam, never shared, and you can leave any time.

— Nilay

or follow by RSSor on X

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text