2014-01-20 59 views
1

gruntfile.js是:咕嚕不會加載節點服務器

'use strict'; 

module.exports = function(grunt) { 
    // Project Configuration 
    grunt.initConfig({ 
     pkg: grunt.file.readJSON('package.json'), 
     watch: { 
      jade: { 
       files: ['app/views/**'], 
       options: { 
        livereload: true, 
       }, 
      }, 
      js: { 
       files: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'], 
       tasks: ['jshint'], 
       options: { 
        livereload: true, 
       }, 
      }, 
      html: { 
       files: ['public/views/**'], 
       options: { 
        livereload: true, 
       }, 
      }, 
      css: { 
       files: ['public/css/**'], 
       options: { 
        livereload: true 
       } 
      } 
     }, 
     jshint: { 
      all: { 
       src: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'], 
       options: { 
        jshintrc: true 
       } 
      } 
     }, 
     nodemon: { 
      dev: { 
       options: { 
        file: 'server.js', 
        args: [], 
        ignoredFiles: ['public/**'], 
        watchedExtensions: ['js'], 
        nodeArgs: ['--debug'], 
        delayTime: 1, 
        env: { 
         PORT: 3000 
        }, 
        cwd: __dirname 
       } 
      } 
     }, 
     concurrent: { 
      tasks: ['nodemon', 'watch'], 
      options: { 
       logConcurrentOutput: true 
      } 
     }, 
     mochaTest: { 
      options: { 
       reporter: 'spec', 
       require: 'server.js' 
      }, 
      src: ['test/mocha/**/*.js'] 
     }, 
     env: { 
      test: { 
       NODE_ENV: 'test' 
      } 
     }, 
     karma: { 
      unit: { 
       configFile: 'test/karma/karma.conf.js' 
      } 
     } 
    }); 

    //Load NPM tasks 
    grunt.loadNpmTasks('grunt-contrib-watch'); 
    grunt.loadNpmTasks('grunt-contrib-jshint'); 
    grunt.loadNpmTasks('grunt-mocha-test'); 
    grunt.loadNpmTasks('grunt-karma'); 
    grunt.loadNpmTasks('grunt-nodemon'); 
    grunt.loadNpmTasks('grunt-concurrent'); 
    grunt.loadNpmTasks('grunt-env'); 

    //Making grunt default to force in order not to break the project. 
    grunt.option('force', true); 

    //Default task(s). 
    grunt.registerTask('default', ['jshint', 'concurrent']); 

    //Test task. 
    grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']); 
}; 

,當我鍵入grunt,我得到:

$ grunt 
Running "jshint:all" (jshint) task 
>> 69 files lint free. 

Running "concurrent:tasks" (concurrent) task 
Running "nodemon:dev" (nodemon) task 
Running "watch" task 
Waiting... 

通常它說Express started on Port 3000,卻突然事實並非如此。不知道發生了什麼事。有任何想法嗎?

當與-v國旗跑,我得到:

Running tasks: nodemon 

    Running "nodemon" task 

    Running "nodemon:dev" (nodemon) task 
    Verifying property nodemon.dev exists in config...OK 
    File: [no files] 
    Options: file="server.js", args=[], ignoredFiles=["public/**"], watchedExtensions=["js"], nodeArgs=["--debug"], delayTime=1, env={"PORT":3000}, cwd="/Users/shamoon/Sites/blocksearcher" 
    Loading "env.js" tasks...OK 
    + env 
    Loading "gruntfile.js" tasks...OK 
    + default, test 

    Running tasks: watch 

    Running "watch" task 
    Waiting...Verifying property watch exists in config...OK 
    Verifying property watch.jade.files exists in config...OK 
    Verifying property watch.js.files exists in config...OK 
    Verifying property watch.html.files exists in config...OK 
    Verifying property watch.css.files exists in config...OK 
    Live reload server started on port: 35729 


     Watching app/views for changes. 
    Watching app/views/includes for changes. 
    ... 
+0

嘗試使用'-v'標誌運行它以獲取更多信息! –

+0

添加'-v'的輸出 – Shamoon

+0

我已經完成了下面提到的更改,但現在有一些新的錯誤,這是你必須做的嗎? – JehandadK

回答

9

看咕嚕-nodemon的更新日誌:https://github.com/ChrisWren/grunt-nodemon#changelog

您最近必須更新您的依賴關係,並且grunt-nodemon更改了一些屬性。

- file is now script 
- ignoredFiles -> ignore 
- watchedFolders -> watch 
- watchedExtensions -> ext 
2

只需將您的options.file更改爲腳本或保留兩者。

nodemon: { 
    dev: { 
     script: 'server.js', 
     options: { 
      file: 'server.js', 
      args: [], 
      ignoredFiles: ['public/**'], 
      watchedExtensions: ['js'], 
      nodeArgs: ['--debug'], 
      delayTime: 1, 
      env: { 
       PORT: 3000 
      }, 
      cwd: __dirname 
     } 
    } 
} 
+0

謝謝你!你救了我的命! –

+0

不客氣! – bugarin