search

Home  >  Q&A  >  body text

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

命令与返回

1

2

3

4

5

6

7

8

9

<code>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.

</code>

Gruntfile.js 部分

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

<code>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']);

</code>

大家讲道理大家讲道理2939 days ago696

reply all(1)I'll reply

  • 阿神

    阿神2017-04-10 14:25:19

    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 --versionv0.4.1 以上

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

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

    reply
    0
  • Cancelreply