首页 > 解决方案 > 运行 grunt jshint 时出现错误

问题描述

我还在阅读 Steven Foote 的《Learning to Program 》一书,目前正在阅读使用 Grunt 的第 4 章。这篇文章有类似的问题,但问题不同(此人在 Gruntfile.js 中将“f”大写)。

我似乎已经正确安装了 NPM 和 Node

npm@5.10.0 /usr/local/lib/node_modules/npm

andrews-macbook-air:Kittenbook Andrew$ node -v
v8.11.3

这是我的 Gruntfile.js:

module.exports = function(grunt){
grunt.initConfig({
    concat: {
        release: {
            src: ['js/values.js', 'js/prompt.js'],
            dest: 'release/main.js'
        }
    },
    copy: {
        release: {
            src: 'manifest.json',
            dest: 'release/main.js'
        }
    },
    jshint: {
        files: ['js/values.js', 'js/prompt.js']
    }
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTasks('default', ['jshint', 'concat' 'copy']);

在检查我是否正确执行时,我在命令行中运行 grunt jshint,但我得到一个错误

andrews-macbook-air:Kittenbook Andrew$ grunt jshint
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected string
Warning: Task "jshint" not found. Use --force to continue.

Aborted due to warnings.

关于发生了什么的任何想法?

标签: gruntjs

解决方案


推荐阅读