question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`UnhandledSchemeError` when dependency uses `node:assert` imports

See original GitHub issue

What version of Next.js are you using?

11.1.2

What version of Node.js are you using?

14.17.6

What browser are you using?

ff

What operating system are you using?

linux

How are you deploying your application?

vercel

Describe the Bug

In a project which has micromark-util-events-to-acorn@1.0.1 as a dependency, i get the following error when running yarn dev:

Module build failed: UnhandledSchemeError: Reading from "node:assert" is not handled by plugins (Unhandled scheme).

Screenshot_20210903_204738

Things to note about this package: it uses an export map with a “development” user condition, and node:assert is only used there, not in the exported production build.

Expected Behavior

No error.

To Reproduce

  1. git clone https://github.com/stefanprobst/issue-next-webpack-node-imports.git
  2. cd issue-next-webpack-node-imports
  3. yarn && yarn add next@latest && yarn dev
  4. open http://localhost:3000/
  5. See error message

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:19
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
balazsorban44commented, May 3, 2022

Oh, interesting. The reproduction uses 11.1.2, but upgrading to latest does throw the error after all. 👀

It might be because the client-side code elimination tool isn’t able to recognize the module you are using is for server-only.

import fs from "node:fs"

export default function Home() {
  return null
}

export async function getStaticProps() {
  console.log(fs)
  return { props: {} }
}

This works as the code can be analyzed and Next.js will know where the node: import is being used.

Let’s reopen and investigate further.

4reactions
stefanprobstcommented, Nov 5, 2021

I’m still getting this error with next.js 12

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnhandledSchemeError: What is this node:buffer error and ...
Pasted below is a node:buffer error that I've received when using a link to a local route in nextjs. Anyone know how to...
Read more >
Issue with import of a node package : r/learnjavascript - Reddit
got is intended for use in Node apps, not on the client side. These errors all relate to got's internal dependencies on built-in...
Read more >
Node.js v19.3.0 Documentation
In legacy assertion mode, error messages for objects display the objects, often truncated. To use strict assertion mode: import { strict as assert...
Read more >
Builtin Node.js Testing - Whistlr
import test from 'node:test'; import assert from 'node:assert'; ... When used without any further arguments, this will automatically find JS files inside ...
Read more >
node path resolve Code Example - Code Grepper
Type 'IterableIterator<[number, Module]>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found