javascript - 将 chrome devtools 与 browsersync & --inspect 一起使用

标签 javascript node.js debugging gulp google-chrome-devtools

我一辈子都无法锻炼如何使用新的 --inspect 和浏览器同步

gulp.task('browser-sync', ['nodemon'], function () {
    browserSync({
        proxy: 'localhost:17230',
        port: 5000,
        notify: true,
        debug: true
    });
});

我试过 debug true,但这也没有任何作用:(

最佳答案

几个月前我遇到了同样的问题。您可以使用 nodeArgs 将适当的参数传递给 Node 二进制文件,或者,exec 选项也可以。

const nodemon = require('gulp-nodemon');
const browserSync = require('browser-sync');

gulp.task('browser-sync', ['nodemon'], function () {
    browserSync({
        proxy: 'localhost:17230',
        port: 5000,
        notify: true,
        debug: true
    });
});

gulp.task('nodemon', function() {
  let started = false;
  nodemon({
    nodeArgs: ['--inspect=0.0.0.0:17230'], // localhost + port
    // You may also use {exec: 'node --inspect'}
    ext: 'js',
    ignore: ['.idea/*', 'node_modules/*'],
    script: 'server.js',
    tasks: ['lint'],
    verbose: true
    delay: 2000
  })
  .on('start', () => {
    // to avoid nodemon being started multiple times
    if (!started) {
      setTimeout(() => done(), 100);
      started = true;
    }
  });
});

关于javascript - 将 chrome devtools 与 browsersync & --inspect 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45621018/

相关文章:

node.js - 使用 Node.js 和 native Promise 构建堆栈跟踪

javascript - 如何绕过 "Visual Studio Just-In-Time Debugger"提示

javascript - 避免带有 promise 的嵌套回调

javascript - ListView 内可折叠面板的平滑动画

node.js - 在 AfterWork 中调用 Persistent<Function> 回调段错误

javascript - 如何在 HTML 中调用 JavaScript 函数而不是 href

.net - Visual Studio 调试和处置对象

javascript - aspx页面通过按钮打开超链接

JavaScript .无法理解为什么我的第一个控制台语句给出了未定义的

javascript - 过滤掉对象成员的好习惯用法(javascript)