Skip to main content

[Node.js] Why does Jest fail with ENOENT node:util after upgrading to SDK v8?

Issue

After upgrading to @sentry/node v8, Jest fails on files that import @sentry/node with: ENOENT: no such file or directory, open 'node:util'.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • Node.js SDK v8 and newer

  • Jest older than 27.1.0

Resolution

@sentry/node v8 and newer import Node.js core modules with the node: prefix (for example node:util). Jest versions older than 27.1.0 do not resolve that prefix, so test runs fail with ENOENT when they load @sentry/node.

Upgrade Jest to 27.1.0 or newer, then re-run your tests.

  1. Check your installed Jest version (jest --version or the jest version in package.json).

  2. Upgrade Jest to 27.1.0 or newer.

  3. Reinstall dependencies and run the failing test file again.

If you are already on Jest 27.1.0 or newer and still see ENOENT for node:util, the failure is not this Jest node: gap. Check for other tools in the test pipeline that cannot resolve node:-prefixed builtins.

For the Node SDK v8 migration itself, see the Node.js v7 to v8 migration guide.

Did this answer your question?