Я вызываю инспектора в моем проекте npm, используя --inspect-brk в файле индекса.Затем я открываю файл в консоли разработчика Google Chrome.
Я хочу отладить скрипт, на который есть ссылка в индексном файле.
const script = require ./script/index
Как мне это сделать?сделай это?Если я запускаю node --inspect-brk ./script/index.js
, то сценарий не выполняется, так как ему требуются параметры из моего файла ./index.js.
Мой module.exports экспортирует обещание с большим количеством цепочек затем.
>>107 const promiseResults = function (labelsToGet) {
108 Promise.all(labelsToGet.map(getLabel))
109 ¦ .then(labels => Promise.all(labels.map(getLabelRelease)))
110 ¦ .then(labels => Promise.all(labels.map(getRelease)))
111 ¦ .then((labels) => {
112 ¦ ¦ pushTracklists(labels)
113 ¦ ¦ ¦ .then((tracks) => {
--114 ¦ ¦ ¦ ¦ console.log('Start writing export.csv file.');
>>115 ¦ ¦ ¦ ¦ jsonexport(tracks, (err, csv) => {
--116 ¦ ¦ ¦ ¦ ¦ if (err) return console.log(err);
>>117 ¦ ¦ ¦ ¦ ¦ fs.writeFile('export.csv', csv, (err) => {
118 ¦ ¦ ¦ ¦ ¦ ¦ if (err) {
--119 ¦ ¦ ¦ ¦ ¦ ¦ ¦ return console.log(err);
120 ¦ ¦ ¦ ¦ ¦ ¦ }
--121 ¦ ¦ ¦ ¦ ¦ ¦ console.log('The file was saved!');
122 ¦ ¦ ¦ ¦ ¦ });
123 ¦ ¦ ¦ ¦ });
124 ¦ ¦ ¦ })
--125 ¦ ¦ ¦ .catch(err => console.log(`Push tracklist error: ${err}`));
126 ¦ })
127 ¦ .catch((err) => {
--128 ¦ ¦ console.log('Get Label Error:', err);
129 ¦ });
130 };
+ 131
>>132 module.exports = function (labelsToGet) {promiseResults(labelsToGet);};
Какой лучший способ сделать это?