nodejs / nodejs/node

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

未关闭
#58,994 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

feature request never-stale
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用 node -p 'await Promise.resolve(123)' --input-type=module 重现该问题,然后比较针对 issue #45924 对 --eval 路径所做的更改。跟踪 --print--input-type=module 的命令行处理;当示例能够成功求值并输出预期结果时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
cli
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。