nodejs / nodejs/node

[Node 20] ESM Loaders no longer have `process.argv` access

Open
#48,577 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

loaders stale
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

20.x

Platform

Darwin MacBook-Pro-2.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?
// foo.mjs
console.log('argv:', process.argv);

// bar.mjs
console.log('hello from bar', process.version);

Run:

$ node --loader ./foo.mjs bar.mjs --hello=world

Output:

$ node --loader ./foo.mjs bar.mjs --hello=world
# (node:37260) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
# (Use `node --trace-warnings ...` to show where the warning was created)
# argv: [
#   '/.../.volta/tools/image/node/18.12.1/bin/node',
#   '/.../bar.mjs',
#  '--hello=world'
# ]
# hello from bar v18.12.1

$ volta install node@20.2.0 # or any 20.x
$ node --loader ./foo.mjs bar.mjs --hello=world
# (node:37288) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
# (Use `node --trace-warnings ...` to show where the warning was created)
# argv: [ '/.../.volta/tools/image/node/20.2.0/bin/node' ]
# hello from bar v20.2.0
How often does it reproduce? Is there a required condition?

Every time.

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

Have access to process.argv

What do you see instead?

Doesn't receive any arguments beyond node path

Additional information

This is a breaking change introduced by #44710 & it was not listed in the PR notes.

Additionally, this breaking change wasn't listed in the 20.x Changelog

As indicated by https://github.com/nodejs/node/pull/44710#issuecomment-1609957745, the knowledge of this impact is assumed based on the user understanding (& awareness) of loaders now being off main thread.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Node 18.x and 20.x commands shown in the issue with foo.mjs and bar.mjs. Read the linked #44710 discussion and the Custom ESM Loader Hooks section of doc/changelogs/CHANGELOG_V20.md to understand the intended behavior. Done means resolving the process.argv regression or documenting the confirmed breaking change in the appropriate release notes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.