在调试模式下使用终端工具包 |网络风暴
Using terminal-kit package in debug mode | WebStorm
我正在尝试在 Webstorm 中调试代码 (Shift+F9),但出现错误 "Error: Terminal is not capable"
var term = require( 'terminal-kit' ).terminal ;
var history = [ 'John' , 'Jack' , 'Joey' , 'Billy' , 'Bob' ] ;
var autoComplete = [
'Barack Obama' , 'George W. Bush' , 'Bill Clinton' , 'George Bush' ,
'Ronald W. Reagan' , 'Jimmy Carter' , 'Gerald Ford' , 'Richard Nixon' ,
'Lyndon Johnson' , 'John F. Kennedy' , 'Dwight Eisenhower' ,
'Harry Truman' , 'Franklin Roosevelt'
] ;
term( 'Please enter your name: ' ) ;
var input = await term.inputField(
{ history: history , autoComplete: autoComplete , autoCompleteMenu: true }
).promise ;
term.green( "\nYour name is '%s'\n" , input ) ;
process.exit()
当我运行终端中的相同代码一切正常
你的代码对我来说失败 SyntaxError: await is only valid in async function
...无论如何,我想错误发生是因为 WebStorm 中的节点控制台是非 Tty,因为节点进程以 input/output 流重定向启动.
您可以通过为 Node.js 启用终端控制台来解决此问题。为此,请尝试以下操作:
- 选择帮助 |在主菜单上找到操作...;
- 键入
registry
以找到 注册表
- 在那里找到
nodejs.console.use.terminal
键并启用它。
这应该可以做到
密钥在 2018.2 之后的所有 IDE 中都可用,但您需要安装 Node.js 插件
我正在尝试在 Webstorm 中调试代码 (Shift+F9),但出现错误 "Error: Terminal is not capable"
var term = require( 'terminal-kit' ).terminal ;
var history = [ 'John' , 'Jack' , 'Joey' , 'Billy' , 'Bob' ] ;
var autoComplete = [
'Barack Obama' , 'George W. Bush' , 'Bill Clinton' , 'George Bush' ,
'Ronald W. Reagan' , 'Jimmy Carter' , 'Gerald Ford' , 'Richard Nixon' ,
'Lyndon Johnson' , 'John F. Kennedy' , 'Dwight Eisenhower' ,
'Harry Truman' , 'Franklin Roosevelt'
] ;
term( 'Please enter your name: ' ) ;
var input = await term.inputField(
{ history: history , autoComplete: autoComplete , autoCompleteMenu: true }
).promise ;
term.green( "\nYour name is '%s'\n" , input ) ;
process.exit()
当我运行终端中的相同代码一切正常
你的代码对我来说失败 SyntaxError: await is only valid in async function
...无论如何,我想错误发生是因为 WebStorm 中的节点控制台是非 Tty,因为节点进程以 input/output 流重定向启动.
您可以通过为 Node.js 启用终端控制台来解决此问题。为此,请尝试以下操作:
- 选择帮助 |在主菜单上找到操作...;
- 键入
registry
以找到 注册表 - 在那里找到
nodejs.console.use.terminal
键并启用它。
这应该可以做到
密钥在 2018.2 之后的所有 IDE 中都可用,但您需要安装 Node.js 插件