grunt 使用 grunt-contrib-livereload 时提示 Warning: Arguments to path.resolve must be strings Use --force to continue.


命令与返回


 P:\ms>grunt live
Running "livereload-start" task
... Starting Livereload server on 35729 ...

Running "connect:livereload" (connect) task
Warning: Arguments to path.resolve must be strings Use --force to continue.

Aborted due to warnings.

Gruntfile.js 部分


 livereload: {
        port: 35729 // Default livereload listening port.
},
connect: {
    livereload: {
        options: {
            port: 9001,
            hostname: 'localhost',
            base: '.',
            middleware: function(connect, options) {
                return [lrSnippet, folderMount(connect, options.base)]
            }
        }
    }
},
regarde: {
    jade: {
        files: '*.jade',
        tasks: ['jade']
    },
    html: {
        files: ['index.html', 'css/my.css', 'Gruntfile.js'],
        tasks: ['jsbeautifier', 'livereload']
    },
    coffee: {
        files: 'js/my.coffee',
        tasks: 'coffee'
    }
},

grunt.registerTask('live', ['livereload-start', 'connect', 'regarde']);

grunt node.js JavaScript

放开那大妈 10 years, 8 months ago
  1. Grunt 的版本?请尝试升级一下,这样的问题已经多次提交 issues,升级可解决(包括插件的版本)

  2. 如果升级不见效,请跟随以下步骤:

    1. npm uninstall grunt-cli -g
    2. npm uninstall grunt -g
    3. npm cache clean -g
    4. npm install grunt-cli -g
  3. 之后请确认你的 grunt --version v0.4.1 以上

  4. 请确认你没有安装多个 grunt, where grunt 查看一下

BTW,别再用 regard + livereload 了,以前 contrib-watch 不好用才用这俩,现在 watch 简直 awesome,配置 livereload 简单无比。

诺德皇家卫士 answered 10 years, 8 months ago

Your Answer