Grunt 启动后报错Warning: Task "default" not found.实在找不到问题出在哪?麻烦帮一下忙

今天学习grunt,在配置好之后启动出现一下问题:

Loading "gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected token .
Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.

我的gruntfile.js

'use strict'
module.exports = function(grunt){
    grunt.initConfig({
        // watch的配置
        watch : {
            jade :{
                files : ['views/**'],
                options : {
                    livereload : true
                }
            },
            js : {
                files : ['page/**'],
                options : {
                    livereload : true
                }
            }
        },
        nodemon : {
            dev : {
                script : 'app.js',
                options : {
                    args : [],
                    nodeArgs : ['--debug'],
                    ignore : ['README.md', 'node_modules/**', '.DS_Store'],
                    ext : 'js',
                    watch : [./],
                    delay : 1000,
                    env : {
                        PORT : '3000'
                    },
                    cwd : __dirname
                }
            }
        },
        concurrent : {
            tasks : ['nodemon','watch'],
            options : {
                logConcurrentOutput : true
            }
        }

    }); 

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-nodemon');
    grunt.loadNpmTasks('grunt-concurrent');
    
    grunt.option('force', true);
    grunt.registerTask('default', ['concurrent']);
}

package.json

{
  "name": "myblog",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "dependencies": {
    "bootstrap": "^3.3.7",
    "express": "^4.16.3",
    "grunt": "^1.0.2",
    "grunt-contrib-watch": "^1.0.1",
    "jade": "^1.11.0",
    "serve-static": "^1.13.2",
    "wangeditor": "^3.1.1"
  },
  "devDependencies": {
    "grunt-concurrent": "^2.3.1",
    "grunt-nodemon": "^0.4.2"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

格式括号等问题我都排查了好几遍,然后里面运用到的3个组件都分别去查看了相关文档,也在Stack Overflow查了相关的问题,但是那些解答都非常私人化.哪位大大可以帮忙排查一下.

阅读 4.3k
1 个回答

你的这个文件我用VSCode打开就有报错了。 27行的watch : [./],应该是watch : ["./"],

建议你给你的编辑器配置下语法检查插件,比如ESlint。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题