nodejs / nodejs/node

Using 'import' crashes the REPL

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

还没有人认领这个 Issue。

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

描述

Version

26.1.0

Platform
Windows
Subsystem

repl

What steps will reproduce the bug?
C:\>node
Welcome to Node.js v26.1.0.
Type ".help" for more information.
> import
node:internal/readline/emitKeypressEvents:74
            throw err;
            ^

SyntaxError: Unexpected token (1:6)
    at pp$4.raise (node:internal/deps/acorn/acorn/dist/acorn:3766:15)
    at pp$9.unexpected (node:internal/deps/acorn/acorn/dist/acorn:799:10)
    at pp$9.expect (node:internal/deps/acorn/acorn/dist/acorn:793:28)
    at pp$8.parseImportSpecifiers (node:internal/deps/acorn/acorn/dist/acorn:2020:10)
    at pp$8.parseImport (node:internal/deps/acorn/acorn/dist/acorn:1966:30)
    at pp$8.parseStatement (node:internal/deps/acorn/acorn/dist/acorn:1019:51)
    at pp$8.parseTopLevel (node:internal/deps/acorn/acorn/dist/acorn:856:23)
    at Parser.parse (node:internal/deps/acorn/acorn/dist/acorn:611:17)
    at Parser.parse (node:internal/deps/acorn/acorn/dist/acorn:678:37)
    at parse (node:internal/deps/acorn/acorn/dist/acorn:6254:19) {
  pos: 6,
  loc: Position { line: 1, column: 6 },
  raisedAt: 6
}

Node.js v26.1.0

C:\>
How often does it reproduce? Is there a required condition?

everytime

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

no crash

What do you see instead?

crash

Additional information

No response

贡献指南

打开贡献指南

从这里开始

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

调研方向

使用独立的 import 输入在 Windows Node.js REPL 中重现该故障,然后跟踪 REPL 经过 internal/readline/emitKeypressEvents 以及报告中显示的 Acorn parseImport 堆栈的路径。完成的标准是输入 import 不再导致 REPL 崩溃,并且为该输入提供回归覆盖。

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

评估

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

把新 issue 发到你的邮箱

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