nodejs / nodejs/node

Make `--print` respect --input-type=module

Open
#58,994 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What is the problem this feature will solve?

This doesn't work, but it should:

node -p 'await Promise.resolve(123)' --input-type=module

Related to https://github.com/nodejs/node/issues/45924#issuecomment-2751207324 - but that was about --print and --eval. It seems to be fixed for --eval but not for --print

Note: bun -p 'await Promise.resolve(123)' works

What is the feature you are proposing to solve the problem?

Make a similar change to whatever fixed #45924

What alternatives have you considered?

bun

Note: node -e 'console.log(await Promise.resolve(123))' --input-type=module does work, but it's not always possible to use a console.log, especially when using node -p in a piped bash expression

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

Reproduce the issue with node -p 'await Promise.resolve(123)' --input-type=module, then compare how the --eval path was changed for issue #45924. Trace the command-line handling for --print and --input-type=module; done means the example evaluates successfully with the expected printed result.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.