I encountered a situation where node.js could not be debugged. The application entry file uses Interactive mode. It is with inquirer npm package.
I have used the debug tool of node,it doesn't work.
Here is the code:
const inquirer = require('inquirer');
const commonQuestions = [{...}]; // some code is omitted here
const shortCutQuestions = [{
type: 'rawlist',
name: 'cmd',
message: '请选择快捷命令(直接输入数字进行选择):',
pageSize: 10,
default: 0,
choices: cacheCommands,
}];
const shortCutResolveFunc = ({ cmd }) => {
updateCommands(cmd);
try {
signale.watch(`cmd: ${cmd}`);
const [globalCmd, ...cmdLineArgs] = cmd.split(' ');
spawn.sync(globalCmd, cmdLineArgs, { stdio: 'inherit' });
} catch (err) {
console.log(pe.render(err));
}
};
inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));
inquirer
.prompt(isCommonMode ? commonQuestions : shortCutQuestions)
.then(isCommonMode ? commonResolveFunc : shortCutResolveFunc);