node icon indicating copy to clipboard operation
node copied to clipboard

regression in 21.4.0 when using `esm` package

Open jeremymeng opened this issue 1 year ago • 3 comments

Version

v21.4.0

Platform

Linux codespaces-8a914d 6.2.0-1016-azure #16~22.04.1-Ubuntu SMP Tue Oct 10 17:11:51 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

  1. npm init -y
  2. npm add esm
  3. create a file test.js with the following content
import { writeFileSync } from "fs";
console.log("hello");
  1. node -r esm test.js

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

same as in v21.3.0

/workspaces/working/mocha/esm-test $ nvm use v21.3.0 Now using node v21.3.0 (npm v10.2.4) /workspaces/working/mocha/esm-test $ node -r esm test.js hello

What do you see instead?

content of esm.js is dumped to console for a TypeError

TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
    at node:internal/main/run_main_module:28:49

Node.js v21.4.0

Additional information

No response

jeremymeng avatar Dec 06 '23 23:12 jeremymeng

This is from https://github.com/nodejs/node/pull/50907

/cc @ronag @anonrig

targos avatar Dec 07 '23 11:12 targos

This is also reproducible in node 22.x.x, 🙇 so revert needs to be applied there I think.

yoroshikun avatar May 06 '24 03:05 yoroshikun

This isn't really a bug. We changed some undocumented internals that esm relied on, knowing it would break. Anyone can fork esm to update it accordingly; reverting the change would break other things now.

GeoffreyBooth avatar May 06 '24 04:05 GeoffreyBooth

Given @GeoffreyBooth's response, I've closed this as wontfix. If you disagree, feel free to reopen / leave a comment

avivkeller avatar Jul 16 '24 21:07 avivkeller