使用带有browsersync&--inspect的chrome devtools

问题描述 投票:2回答:1

我不能为我的生活锻炼如何使用新的--inspect与浏览器同步

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

我试过调试true,但这也没有做任何事:(

javascript node.js debugging gulp google-chrome-devtools
1个回答
1
投票

几个月前我遇到了同样的问题。您可以使用nodeArgs以便将适当的参数传递给节点二进制,或者,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;
    }
  });
});
© www.soinside.com 2019 - 2024. All rights reserved.