我遇到了node.js无法调试的情况。应用程序入口文件使用交互模式。它与 enquirer npm 包一起使用。
\n我用过node的debug工具,没用。
\n这是代码:
\nconst inquirer = require(\'inquirer\');\nconst commonQuestions = [{...}]; // some code is omitted here\nconst shortCutQuestions = [{\n type: \'rawlist\',\n name: \'cmd\',\n message: \'\xe8\xaf\xb7\xe9\x80\x89\xe6\x8b\xa9\xe5\xbf\xab\xe6\x8d\xb7\xe5\x91\xbd\xe4\xbb\xa4(\xe7\x9b\xb4\xe6\x8e\xa5\xe8\xbe\x93\xe5\x85\xa5\xe6\x95\xb0\xe5\xad\x97\xe8\xbf\x9b\xe8\xa1\x8c\xe9\x80\x89\xe6\x8b\xa9)\xef\xbc\x9a\',\n pageSize: 10,\n default: 0,\n choices: cacheCommands,\n}];\n\nconst shortCutResolveFunc = ({ cmd }) => {\n updateCommands(cmd);\n\n try {\n signale.watch(`cmd: ${cmd}`);\n\n const [globalCmd, ...cmdLineArgs] = cmd.split(\' \');\n\n spawn.sync(globalCmd, cmdLineArgs, { stdio: \'inherit\' });\n } catch (err) {\n console.log(pe.render(err));\n }\n};\n\ninquirer.registerPrompt(\'autocomplete\', require(\'inquirer-autocomplete-prompt\'));\n\ninquirer\n .prompt(isCommonMode ? commonQuestions : shortCutQuestions)\n .then(isCommonMode ? commonResolveFunc : shortCutResolveFunc);\nRun Code Online (Sandbox Code Playgroud)\n node.js ×1