简体   繁体   English

运行Gulp命令时nodemon应用程序崩溃

[英]nodemon app crash when running Gulp command

My React app is crashing when I am running Gulp command. 当我运行Gulp命令时,我的React应用程序崩溃了。 It was working perfectly few hours back. 几小时前,它运行得非常好。 I just changed my node version from 6.2.1 to 6.2.2 as I wanted to deploy the application on Azure platform. 我只是想将节点版本从6.2.1更改为6.2.2,因为我想在Azure平台上部署该应用程序。 I did change the node version like this 我确实这样更改了节点版本

npm -g install n used 

npm cache clean -f

n 6.2.2

Now when I run Gulp command I am getting a crash statement this in terminal (nodemon appcrash) 现在,当我运行Gulp命令时,我在终端中收到一条崩溃声明(nodemon appcrash)

[09:43:30] Requiring external module babel-register
[09:43:31] Using gulpfile ~/Downloads/Frontend-Master-master/gulpfile.babel.js
[09:43:31] Starting 'build:watch'...
[09:43:31] Starting 'copy:assets'...
[09:43:31] Starting 'copy:vendors'...
  Cleaned build/ 
  Copied 12 asset entries.
[09:43:31] Finished 'copy:vendors' after 179 ms
[09:43:31] Starting 'copy:views'...
[09:43:31] copied views all files 1.87 kB
[09:43:31] Finished 'copy:views' after 39 ms
[09:43:31] Starting 'copy:public'...
[09:43:31] Finished 'copy:public' after 7.85 ms
[09:43:31] Finished 'copy:assets' after 233 ms
[09:43:31] Starting 'bundle:dll'...
DLL Bundled.
Hash: 7ed86431bba8f924d2d1
Version: webpack 1.13.3
Time: 2869ms
        Asset     Size  Chunks             Chunk Names
dll.vendor.js  3.08 MB       0  [emitted]  vendor
[09:43:34] Finished 'bundle:dll' after 2.9 s
[09:43:34] Starting 'bundle'...
Hash: 83008c2f0264de7933ac
Version: webpack 1.13.3
Time: 412ms
           Asset     Size  Chunks             Chunk Names
server-bundle.js  24.4 kB       0  [emitted]  main
  -- server:watch bundled.
Hash: 4fcb73c5d659e0ff6d79
Version: webpack 1.13.3
Time: 4737ms
                               Asset     Size  Chunks             Chunk Names
552d3ad10bba822801dbc6245f754eaa.mp4  21.1 MB          [emitted]  
                      main-bundle.js  1.36 MB       0  [emitted]  main
  -- client bundled.
[09:43:39] Finished 'bundle' after 4.75 s
[09:43:39] Starting 'start:server'...
Starting Node Server...
[09:43:39] Finished 'start:server' after 38 ms
[09:43:39] Starting 'watch:sync'...
[09:43:39] [nodemon] 1.11.0
[09:43:39] [nodemon] to restart at any time, enter `rs`
[09:43:39] [nodemon] watching: build/server-bundle.js
[09:43:39] [nodemon] starting `node --debug --inspect build/server-bundle.js`
Server Restarted: Reloading BrowserSync.
[tessact: ] Reloading Browsers...
node: bad option: --inspect
[09:43:39] [nodemon] app crashed - waiting for file changes before starting...
[tessact: ] Proxying: http://localhost:4200
[tessact: ] Access URLs:
 ----------------------------------------
       Local: http://localhost:3000
    External: http://192.168.168.144:3000
 ----------------------------------------
          UI: http://localhost:3001
 UI External: http://192.168.168.144:3001
 ----------------------------------------
[tessact: ] Watching files...
[09:43:39] Finished 'watch:sync' after 356 ms
[09:43:39] Starting 'watch:assets'...
[09:43:39] Finished 'watch:assets' after 16 ms
[09:43:39] Finished 'build:watch' after 8.29 s
[09:43:39] Starting 'default'...
[09:43:39] Finished 'default' after 2.14 μs
webpack built 4fcb73c5d659e0ff6d79 in 2992ms
Hash: 4fcb73c5d659e0ff6d79
Version: webpack 1.13.3
Time: 2992ms
                               Asset     Size  Chunks             Chunk Names
552d3ad10bba822801dbc6245f754eaa.mp4  21.1 MB          [emitted]  
                      main-bundle.js  1.36 MB       0             main
webpack: bundle is now VALID.

Here is my gulp file 这是我的gulp文件

gulp.task('default', ['build:watch']);
gulp.task('build:prod', cb=> {
    WATCH = false;
    run('copy:assets', 'bundle', cb);
});
gulp.task('build:watch', cb=> {
    WATCH = true;
    run('copy:assets', 'bundle:dll', 'bundle', 'start:server', 'watch:sync', 'watch:assets', cb);
});

gulp.task('bundle:dll', cb=> {
    if (IS_PROD)
        return cb();

    var dllBundler = webpack(DLLConfig);

    return new Promise((resolve, reject)=> {
        dllBundler.run((err, stats)=> {
            if (err) {
                return reject(err)
            }
            console.log('DLL Bundled.')
            console.log(stats.toString({colors: true, chunks: false}))
            resolve()
        });
    })
});

gulp.task('bundle', cb => {
    var count = 0;
    clientBundler = webpack(ClientConfig)
    serverBundler = webpack(ServerConfig);
    const bundleComplete = (msg) => (err, stats)=> {
        if (err)
            throw new gutil.PluginError(msg + ':bundle', err)
        console.log( stats.toString({ colors: true, chunks: false }) );
        console.log( `  -- ${msg} bundled.`);
        if (++count === 2) cb();
    }

    clientBundler.run(bundleComplete('client'));
    WATCH
        ? serverBundler.watch(750, bundleComplete('server:watch'))
        : serverBundler.run(bundleComplete('server'))
});

gulp.task('start:server', cb=> {
    console.log('Starting Node Server...');
    $.nodemon({
        script: 'build/server-bundle.js',
        watch: ['build/server-bundle.js'],
        ext: 'js',
        ignore: ['!build/public', '!build/vendor', 'src/client'],
        env: Object.assign({NODE_ENV: 'development', DEBUG: 'tessact:*'}, process.env),
        nodeArgs: ['--debug', '--inspect']
    }).on('start', cb=>{
        console.log('Server Restarted: Reloading BrowserSync.');
        browserSync.reload();
    });
    cb();
});

gulp.task('watch:sync', cb=> {
    process.on('exit', () => browserSync.exit());
    browserSync({
        logPrefix: 'tessact: ',
        open: false, notify: true,
        port: (process.env.BS_PORT || 3000),
        proxy: {
            target: 'localhost:4200',
            middleware: [
                webpackDevMiddleware(clientBundler, {
                    publicPath: ClientConfig.output.publicPath,
                    stats: {colors: true, chunks: false}
                }),
                webpackHotMiddleware(clientBundler)
            ]
        },
        files: [
            'build/public/**/*.css',
            '!build/public/**/*.js'
        ]
    }, cb);
});

gulp.task('copy:vendors', vendorsTask);
gulp.task('copy:assets', cb=> {
    run('copy:vendors', 'copy:views', 'copy:public', cb);
});
gulp.task('copy:views', cb=> {
    return (
        gulp.src('./src/server/views/**/*.jade')
            .pipe($.changed('./build/views'))
            .pipe($.size({title: 'copied views', pretty: true}))
            .pipe( gulp.dest('./build/views'))
    )
});
gulp.task('copy:public', cb=> {
    return (
        gulp.src('./src/public/**/*.*')
            .pipe($.changed('./build/public/'))
            .pipe($.size({title: 'copied public', pretty: true}))
            .pipe(gulp.dest('./build/public/'))
    )
});
gulp.task('watch:assets', cb=> {
    gulp.watch('./src/server/views/**/*.jade', {interval: 1000}, ['copy:views']);
    gulp.watch('./src/public/**/*.*', {interval: 1000}, ['copy:public']);
    cb()

在此处输入图片说明

I solved the issue by upgrading to latest stable version of node js via 我通过升级到Node js的最新稳定版本来解决了这个问题

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Cheers 干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM