2016-05-21 9 views
2

私はgrunt watchのライブリロードオプションを使用しようとするたびにこの問題にぶつかります。 どのポートを使用しても、「致命的なエラー:ポートxxxxは既に別のプロセスで使用されています。」というメッセージが表示され続けます。 使用中のすべてのポートがリストされていて、リストに表示されない乱数を選択しても助けになりません:xxxxをgruntfileで最後に使用したポートに置き換えます。Grunt:ライブリロードが動作しません

マイgruntfile自体:

module.exports = function (grunt) { 

grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), 

    watch: { 

     options: { 
      livereload: true 
     }, 

     js: { 
      files: ['.dev/**/*.js'], 
      tasks: ['concat', 'uglify', 'watch'], 
     }, 
     scss: { 
      files: ['./dev/scss/*.scss'], 
      tasks: ['sass', 'concat', 'watch'], 
      options: { 
       reload: true, 
       livereload: false, 

      } 
     }, 
     html: { 
      files: ['./dev/**/*.html', 'watch'], 
      tasks: ['copy', 'watch'], 
     }, 
     grunt: { 
      files: ['Gruntfile.js'], 
      tasks: ['watch'], 
     }, 
    }, 

    concat: { 
     js: { 
      src: ['dev/js/script1.js', 'dev/js/script2.js'], 
      dest: 'dev/js/script.js', 
     }, 
     css: { 
      src: ['./dev/css/nav.css', './dev/css/anim.css', './dev/css/style.css'], 
      dest: './dist/css/style.css', 
     }, 
    }, 

    uglify: { 
     build: { 
      src: 'dev/js/script.js', 
      dest: 'dist/js/script.min.js' 
     } 
    }, 

    sass: {        // Task 
     dev: {       // Target 
      files: {       // Dictionary of files 
       './dev/css/style.css': './dev/scss/style.scss',  // 'destination': 'source' 
      }, 
      tasks: ['copy'], 
     } 
    }, 

    copy: { 
     main: { 
      expand: true, 
      cwd: './dev/html', 
      src: '*.html', 
      dest: './dist/html/' 
     }, 
    }, 
}); 

// Load the plugin that provides the "uglify" task. 
grunt.loadNpmTasks('grunt-contrib-uglify'); 
grunt.loadNpmTasks('grunt-contrib-watch'); 
grunt.loadNpmTasks('grunt-contrib-concat'); 
grunt.loadNpmTasks('grunt-contrib-copy'); 
grunt.loadNpmTasks('grunt-contrib-sass'); 


// Default task(s). 
grunt.registerTask('default', ['concat', 'uglify', 'sass', 'copy', 'watch']); 

}; 

私はまだNPM、イサキなどに新たなんだ、と同様ヨーマンを使用してこの問題を持っていました。 (私はWebstormを使用しています)のすべてのポートを自動的に聞くアプリケーションがありますか? しかし、私はそれを閉鎖し、崇高な使用と端末とき、それはすべてのランダムなポートが既に使用中

答えて

1

であると言って続けているあなたは再帰的に時計を呼んでいるように見えます。..

はあなたのgruntfileのこの部分を取りますたとえば、

watch: { // hey grunt, you now know of a task called 'watch' 
    .... 
    html: { 
     files: ['./dev/**/*.html', 'watch'], // here are the files to watch 
     tasks: ['copy', 'watch'], // and oh, hey, when you run watch, make 
            // sure to run watch again, recursively, forever 
    } 

これはどこにあるのか分かります。ウォッチタスクが再度実行しようとしたときに既に実行されているため、ポートが使用中です。時計の各サブセクションにタスクとして「時計」を登録する必要はありません。希望は助ける:)

+0

おっと、私は今まで尋ねてきたはずです!それは魅力のように働く。どうもありがとうございます –

関連する問題